@royaloperahouse/chord 1.12.3 → 1.12.4-b-chord-development
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -5
- package/README.md +248 -40
- package/dist/chord.cjs.development.js +53 -11
- package/dist/chord.cjs.development.js.map +1 -1
- package/dist/chord.cjs.production.min.js +1 -1
- package/dist/chord.cjs.production.min.js.map +1 -1
- package/dist/chord.esm.js +53 -11
- package/dist/chord.esm.js.map +1 -1
- package/dist/components/organisms/AnchorTabBar/AnchorTabBar.style.d.ts +3 -2
- package/dist/types/navigation.d.ts +10 -0
- package/package.json +1 -1
- package/README.GIT +0 -275
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
- Search: change copy
|
|
1
|
+
# CHANGELOG
|
|
3
2
|
|
|
4
|
-
## [1.
|
|
5
|
-
-
|
|
3
|
+
## [1.11.0-a]
|
|
4
|
+
- Pagination: add new component
|
|
6
5
|
|
|
6
|
+
## [1.10.0-a]
|
|
7
|
+
- ContentSummary: make image clickable
|
|
7
8
|
## [1.11.0]
|
|
8
9
|
- Carousels: Rewrite logic that cuts description, to support older browsers
|
|
9
10
|
|
|
@@ -12,13 +13,41 @@
|
|
|
12
13
|
|
|
13
14
|
## [1.9.0]
|
|
14
15
|
- Card: Add a new prop for the hover line color
|
|
16
|
+
## [1.9.0-c]
|
|
17
|
+
- ContentSummary: make image clickable
|
|
18
|
+
|
|
19
|
+
## [1.9.0-b]
|
|
20
|
+
- ContentSummary: change image size
|
|
21
|
+
- SearchBar: Export component
|
|
22
|
+
|
|
23
|
+
## [1.9.0-a]
|
|
24
|
+
- ContentSummary: change image props
|
|
25
|
+
|
|
26
|
+
## [1.9.0]
|
|
27
|
+
- Card: Add a new prop for the hover line color
|
|
28
|
+
|
|
29
|
+
## [1.8.1-h]
|
|
30
|
+
- ContentSummary: add exports
|
|
31
|
+
|
|
32
|
+
## [1.8.1-g]
|
|
33
|
+
- ContentSummary: refactor
|
|
34
|
+
|
|
35
|
+
## [1.8.1-f]
|
|
36
|
+
- ContentSummary: update conditional rendering
|
|
37
|
+
|
|
38
|
+
## [1.8.1-c]
|
|
39
|
+
- ContentSummary: update for Search results
|
|
40
|
+
- ContentSummarySection: remove
|
|
41
|
+
|
|
42
|
+
## [1.8.1-b]
|
|
43
|
+
- Card: add new prop for the line color on hover
|
|
15
44
|
|
|
16
45
|
## [1.8.0]
|
|
17
46
|
- SearchBar: Disable
|
|
18
47
|
|
|
19
48
|
## [1.7.2]
|
|
20
49
|
- Add imageAltText to Card component
|
|
21
|
-
|
|
50
|
+
|
|
22
51
|
## [1.7.0]
|
|
23
52
|
- Add new ContentSummary component
|
|
24
53
|
- Add new ContentSummarySection component
|
package/README.md
CHANGED
|
@@ -1,67 +1,275 @@
|
|
|
1
|
-
# Royal Opera House -
|
|
1
|
+
# Royal Opera House Chord - Front End Design System
|
|
2
2
|
|
|
3
|
-
Welcome to the Royal Opera House
|
|
3
|
+
Welcome to the Royal Opera House Front End Design System, `@royaloperahouse/chord`
|
|
4
4
|
|
|
5
5
|
This package is a library of UI components intended to be used in the ROH website.
|
|
6
6
|
|
|
7
|
+
It uses React, TypeScript, TSDX and Storybook.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
The NPM packages are published at [https://www.npmjs.com/package/@royaloperahouse/chord](https://www.npmjs.com/package/@royaloperahouse/chord)
|
|
10
|
+
|
|
11
|
+
The Storybook for the latest version of the library is hosted at [chord.roh.org.uk](chord.roh.org.uk)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Prerequisites
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
* Make sure the required package dependencies are installed using `yarn install`
|
|
18
|
+
|
|
19
|
+
* **To deploy the storybook publicly** you will need credentials for the **parent** 'Royal Opera House' AWS account in your `~/.aws/credentials` file.
|
|
20
|
+
* The deploy script expects these to be called `[parent]`.
|
|
21
|
+
|
|
22
|
+
* You can find these values at:
|
|
23
|
+
|
|
24
|
+
*AWS 'Your Applications' page -> 'Royal Opera House' -> 'Developer Access' -> 'Command line or programmatic access'*
|
|
25
|
+
|
|
26
|
+
* **To deploy a preview** for demo / QA you will need the `CHROMATIC_PROJECT_TOKEN` -- find this in 1Password
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
* **To publish the NPM package** you will need the ROH `NPM_TOKEN` -- find this in 1Password
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Versioning
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
We use [Semantic Versioning](https://semver.org/) for Chord.
|
|
36
|
+
|
|
37
|
+
Given a version number MAJOR.MINOR.PATCH, increment the:
|
|
38
|
+
|
|
39
|
+
* MAJOR version when you make incompatible library changes
|
|
40
|
+
* MINOR version when you add functionality in a backwards compatible manner
|
|
41
|
+
* PATCH version when you make backwards compatible bug fixes
|
|
42
|
+
|
|
43
|
+
When you create a new release always update the `CHANGELOG` and `package.json`
|
|
44
|
+
|
|
45
|
+
Increment your version from the latest stable version on `chord-releases`
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## Deploying the Storybook
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
### **1. To build and deploy locally**
|
|
52
|
+
|
|
53
|
+
You can quickly build and serve the contents of `/storybook-static` from your local machine, for development and manual testing. To do this run:
|
|
9
54
|
|
|
10
55
|
```bash
|
|
11
|
-
|
|
56
|
+
yarn storybook
|
|
12
57
|
```
|
|
58
|
+
|
|
59
|
+
By default the storybook will be accessible at
|
|
60
|
+
[http://localhost:6006/]()
|
|
61
|
+
|
|
62
|
+
The server will hot-reload on most changes.
|
|
63
|
+
|
|
64
|
+
### **2. To deploy a preview version remotely**
|
|
65
|
+
|
|
66
|
+
You can deploy a release candidate, or work-in-progress to [Chromatic](https://www.chromatic.com/) for showcase or QA.
|
|
67
|
+
|
|
68
|
+
**NOTE:** you will need the `CHROMATIC_PROJECT_TOKEN` as described in *Prerequisites* above.
|
|
69
|
+
|
|
70
|
+
Either set the token as a shell variable or use a `.env` file in the chord root directory containing the token, as so:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
CHROMATIC_PROJECT_TOKEN=tokengoeshere
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Run:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
yarn deploy-storybook-dev
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
to build and deploy the storybook from your repo to Chromatic.
|
|
83
|
+
|
|
84
|
+
You will find the address of your deployed storybook in the console output, looking something like this:
|
|
85
|
+
|
|
86
|
+
`→ View your Storybook at https://randomHexString-randomAlphabeticalString.chromatic.com`
|
|
87
|
+
|
|
88
|
+
### **3. To deploy a release version**
|
|
89
|
+
|
|
90
|
+
You can deploy the contents of `./storybook-static` to S3 as a static site, which is permanently accessible at [chord.roh.org.uk](chord.roh.org.uk)
|
|
91
|
+
|
|
92
|
+
**NOTE:** To do this you will need the correct `AWS` credentials set up, as described in *Prerequisites* above.
|
|
93
|
+
|
|
94
|
+
First build the storybook using:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
yarn build-storybook
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
then run:
|
|
101
|
+
|
|
13
102
|
```bash
|
|
14
|
-
|
|
103
|
+
yarn deploy-storybook
|
|
15
104
|
```
|
|
16
105
|
|
|
17
|
-
|
|
106
|
+
> **IMPORTANT:** This URL is intended to showcase the latest stable version of Chord, it should be kept up to date with the main `chord-releases` branch and should **only** be used for release versions. If you want to deploy a development version follow the steps above under *To deploy a preview version remotely*.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
## Releasing a New Package Version
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
This is the procedure for releasing a new Chord NPM package.
|
|
113
|
+
|
|
114
|
+
There are two types of package:
|
|
115
|
+
|
|
116
|
+
A **snapshot** can be published to use a development version of the Chord library in our frontend staging environments, to perform integrated, manual testing.
|
|
117
|
+
|
|
118
|
+
A **stable** package is published for use in production.
|
|
119
|
+
|
|
120
|
+
**NOTE:** You will need the `NPM_TOKEN`, as described in 'Prerequisites' above.
|
|
18
121
|
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
Footer, GlobalStyles, ThemeProvider, ThemeType,
|
|
22
|
-
} from '@royaloperahouse/chord';
|
|
122
|
+
### **1. To release a snapshot version**
|
|
23
123
|
|
|
124
|
+
> **IMPORTANT:** Make sure you always publish your **snapshots** from `chord-development` after merging in your feature branch.
|
|
125
|
+
|
|
126
|
+
For snapshots, `RELEASE_VERSION` should be the same as the latest **stable** version of the Chord Library, as found in `chord-releases`, followed by an **unused** lowercase letter.
|
|
127
|
+
|
|
128
|
+
For example, if the latest stable release was 1.42.0, and the last snapshot published to NPM was 1.42.0-w, you would use RELEASE_VERSION `1.42.0-x`
|
|
129
|
+
|
|
130
|
+
To publish a snapshot use:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
NPM_ROH_TOKEN={NPM_TOKEN} RELEASE_VERSION={RELEASE_VERSION} yarn publish-snapshot
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The version published to NPM will be named, e.g. `1.42.0-a-chord-development`, use this to install the snapshot package in the frontend repos.
|
|
137
|
+
|
|
138
|
+
### **2. To release a stable version**
|
|
139
|
+
|
|
140
|
+
> **IMPORTANT:** Make sure you always publish your **stable** packages from `chord-releases` after merging in your feature branch.
|
|
141
|
+
|
|
142
|
+
For stable releases, increment your version from the latest **stable** version found on `chord-releases`, following the rules described in *Versioning* above, and use this as `RELEASE_VERSION`. (Make sure it matches the version in your `package.json` and `CHANGELOG.md`!)
|
|
143
|
+
|
|
144
|
+
To publish a stable package use:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
NPM_ROH_TOKEN={NPM_TOKEN} RELEASE_VERSION={RELEASE_VERSION} yarn publish-release
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
## Using the Package
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
The package is deployed to NPM, and can be installed using yarn or npm:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npm i --save @royaloperahouse/chord
|
|
158
|
+
```
|
|
159
|
+
```bash
|
|
160
|
+
yarn add @royaloperahouse/chord
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
## Testing
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
To **Lint** the package use:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
yarn lint
|
|
171
|
+
# Use the --fix option to perform automatic fixes
|
|
24
172
|
```
|
|
25
|
-
## Sample
|
|
26
173
|
|
|
27
|
-
|
|
174
|
+
To run the **unit tests** (using Jest) use:
|
|
28
175
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
} from '@royaloperahouse/chord';
|
|
176
|
+
```bash
|
|
177
|
+
yarn test
|
|
32
178
|
|
|
179
|
+
# Use the -u option to update snapshots if needed
|
|
180
|
+
# Run `yarn test:watch` to re-run tests on changes
|
|
181
|
+
```
|
|
33
182
|
|
|
34
|
-
|
|
35
|
-
<ErrorBoundary>
|
|
36
|
-
<ThemeProvider theme={ThemeType.Core}>
|
|
37
|
-
<GlobalStyles />
|
|
38
|
-
<Wrapper>
|
|
39
|
-
<Header />
|
|
40
|
-
<GlobalStyle />
|
|
41
|
-
<HealthBanner />
|
|
42
|
-
<ErrorBoundary>
|
|
43
|
-
<Content>
|
|
44
|
-
{children}
|
|
45
|
-
</Content>
|
|
46
|
-
</ErrorBoundary>
|
|
47
|
-
<LiveChat />
|
|
48
|
-
</Wrapper>
|
|
49
|
-
<Footer data={footerData} />
|
|
50
|
-
</ThemeProvider>
|
|
51
|
-
</ErrorBoundary>
|
|
52
|
-
);
|
|
183
|
+
To **run and and store the unit tests** for display in storybook use:
|
|
53
184
|
|
|
185
|
+
```bash
|
|
186
|
+
yarn test-storybook
|
|
187
|
+
# Use the -u option to update snapshots if needed
|
|
54
188
|
```
|
|
55
189
|
|
|
56
|
-
## Components
|
|
57
190
|
|
|
58
|
-
|
|
191
|
+
## Development Process
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
### **1. Branching Model**
|
|
195
|
+
* The Chord project lives in the `roh-components` *monorepo*
|
|
196
|
+
* When working on Chord, treat the `roh-components/packages/chord` directory as your root
|
|
197
|
+
* The Chord **development** branch is currently `chord-development`
|
|
198
|
+
* The Chord **main** branch is currently `chord-releases`
|
|
199
|
+
* All work should be done on a correctly named **feature branch** of the format: `issueType/ticketNumber-short-description-of-feature`, e.g. `feature/RD-1234-update-chord-documentation`
|
|
200
|
+
* Always create your feature branch FROM, and submit pull requests TO, the **main** branch
|
|
201
|
+
* For **QA / UAT** of a Chord component in isolation: following review you should deploy a preview version to Chromatic straight from your **feature branch** _without_ merging to development
|
|
202
|
+
* For releasing an **NPM snapshot**: merge your feature branch into the **development** branch and publish the NPM snapshot from there
|
|
203
|
+
|
|
204
|
+
### **2. Detailed Workflow**
|
|
205
|
+
|
|
206
|
+
#### **Before review:**
|
|
207
|
+
|
|
208
|
+
* Git pull the latest version of `chord-releases`
|
|
209
|
+
* Checkout a new, correctly-named feature branch from `chord releases`
|
|
210
|
+
* Do your work on this feature branch
|
|
211
|
+
* Run: `yarn lint`
|
|
212
|
+
* Run: `yarn test`
|
|
213
|
+
* Commit your changes
|
|
214
|
+
* Create a pull request from your feature branch to `chord-releases`
|
|
215
|
+
* Add the appropriate reviewers
|
|
216
|
+
|
|
217
|
+
#### **Before QA / UAT:**
|
|
218
|
+
|
|
219
|
+
After your PR is approved, you have two options:
|
|
220
|
+
|
|
221
|
+
**i.** For QA of a component in isolation:
|
|
222
|
+
|
|
223
|
+
* Follow the steps above in *Deploying the Storybook -> 2. Deploying a preview version remotely*
|
|
224
|
+
* Share the generated Chromatic URL with the appropriate people for QA / UAT
|
|
225
|
+
|
|
226
|
+
**ii.** For integrated testing of a component in the frontend staging environments:
|
|
227
|
+
|
|
228
|
+
* Check out the `chord-development` branch
|
|
229
|
+
* Merge your work in to `chord-development`
|
|
230
|
+
* Follow the steps above under *Publishing a New Package Version -> 1. To release a snapshot version*
|
|
231
|
+
* Git push the updated `chord-development` branch to remote
|
|
232
|
+
* Finally, in the frontend repo:
|
|
233
|
+
|
|
234
|
+
1. Update the `package.json` to reference the new snapshot version
|
|
235
|
+
2. Run: `yarn install`
|
|
236
|
+
3. Deploy the frontend to a staging environment
|
|
237
|
+
|
|
238
|
+
#### **When ready for production:**
|
|
239
|
+
|
|
240
|
+
* Return to your chord **feature branch**
|
|
241
|
+
* Update the chord version in `package.json`, incrementing from the last **stable** release, found in `chord-releases`, and following the rules described in the *Versioning* section
|
|
242
|
+
* Update `CHANGELOG.md`, adding the new version number and a short description of your changes
|
|
243
|
+
* Run: `yarn lint`
|
|
244
|
+
* Run: `yarn test`
|
|
245
|
+
* Run: `yarn test-storybook -u`
|
|
246
|
+
* Run: `yarn build-storybook`
|
|
247
|
+
* Git commit, push, and update your PR for final approval
|
|
248
|
+
* Merge your approved PR to `chord-releases`
|
|
249
|
+
* Follow the steps in *Publishing a New Package Version -> 2. To release a stable version* to publish the NPM package
|
|
250
|
+
* Finally, follow the steps in *Deploying The Storybook -> 3. To deploy a release version*, to update the public Chord Storybook page
|
|
251
|
+
|
|
252
|
+
Once you have successfully published a new release version, you can open a ticket to update to this version in any of the frontend repos.
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
## Notes
|
|
256
|
+
---
|
|
257
|
+
### The `storybook-static` folder
|
|
258
|
+
|
|
259
|
+
This folder contains all the HTML / JS required to deploy the Storybook as a static site. It's autogenerated whenever the Storybook is built and therefore will show up a lot of merge conflicts when you merge other branches into your feature branch. It is best to leave generating the storybook until the later part of your workflow, but in case you run into conflicts earlier, it's ok to just delete the folder and regenerate using:
|
|
260
|
+
|
|
261
|
+
```bash
|
|
262
|
+
yarn build-storybook
|
|
263
|
+
```
|
|
59
264
|
|
|
60
|
-
|
|
265
|
+
For the same reason changes to this folder will cause a lot of big diffs, when looking at a PR, but can mostly be skimmed over unless something looks unusual.
|
|
61
266
|
|
|
62
|
-
|
|
267
|
+
---
|
|
268
|
+
### Examples
|
|
63
269
|
|
|
270
|
+
There is an example implementation in the example folder. Alternatively there are also integration examples in storybook. Make sure to keep these updated so as to showcase the current components available.
|
|
64
271
|
|
|
65
|
-
|
|
272
|
+
---
|
|
273
|
+
### Bundle analysis
|
|
66
274
|
|
|
67
|
-
|
|
275
|
+
Calculate the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `yarn size` and visualize it with `yarn analyze`.
|
|
@@ -3819,7 +3819,7 @@ var SearchBar = function SearchBar(_ref) {
|
|
|
3819
3819
|
"data-testid": "input-html",
|
|
3820
3820
|
ref: inputRef,
|
|
3821
3821
|
className: "search-input",
|
|
3822
|
-
placeholder: "Search
|
|
3822
|
+
placeholder: "Search for anything ROH...",
|
|
3823
3823
|
type: "text",
|
|
3824
3824
|
onChange: function onChange(e) {
|
|
3825
3825
|
onChangeHandler(e);
|
|
@@ -4076,20 +4076,25 @@ var Footer = function Footer(_ref) {
|
|
|
4076
4076
|
};
|
|
4077
4077
|
|
|
4078
4078
|
var _templateObject$x, _templateObject2$i, _templateObject3$b, _templateObject4$6, _templateObject5$4, _templateObject6$4;
|
|
4079
|
-
var
|
|
4079
|
+
var LIST_ITEM_GAP = 32;
|
|
4080
|
+
var AnchorTabbarWrapper = /*#__PURE__*/styled__default.div(_templateObject$x || (_templateObject$x = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: block;\n position: sticky;\n position: -webkit-sticky;\n top: 0;\n background-color: var(--base-color-white);\n z-index: ", ";\n"])), zIndexes.anchor);
|
|
4080
4081
|
var TabsGrid = /*#__PURE__*/styled__default(Grid)(_templateObject2$i || (_templateObject2$i = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: var(--anchor-tabs-height);\n"])));
|
|
4081
4082
|
var TabsWrapper = /*#__PURE__*/styled__default.div(_templateObject3$b || (_templateObject3$b = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n"])));
|
|
4082
|
-
var TabsList = /*#__PURE__*/styled__default.ul(_templateObject4$6 || (_templateObject4$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: ", ";\n display: flex;\n gap:
|
|
4083
|
+
var TabsList = /*#__PURE__*/styled__default.ul(_templateObject4$6 || (_templateObject4$6 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: ", ";\n display: flex;\n gap: ", "px;\n justify-content: ", ";\n align-items: center;\n list-style: none;\n padding: 0;\n margin: 0;\n height: var(--anchor-tabs-height);\n white-space: nowrap;\n overflow: scroll;\n scrollbar-width: none;\n ::-webkit-scrollbar {\n display: none;\n }\n scroll-behavior: smooth;\n\n @media ", " {\n background: linear-gradient(\n 135deg,\n rgba(255, 255, 255, 1) 0%,\n rgba(255, 255, 255, 0.48) 85%,\n rgba(235, 235, 235, 0.4) 99%,\n rgba(255, 255, 255, 0.39) 100%\n );\n }\n\n @media ", " {\n & {\n width: ", ";\n }\n }\n"])), function (_ref) {
|
|
4083
4084
|
var tabsOverflow = _ref.tabsOverflow;
|
|
4084
4085
|
return tabsOverflow ? 'calc(100% - 74px)' : '100%';
|
|
4085
|
-
}, function (_ref2) {
|
|
4086
|
+
}, LIST_ITEM_GAP, function (_ref2) {
|
|
4086
4087
|
var tabsOverflow = _ref2.tabsOverflow;
|
|
4087
4088
|
return tabsOverflow ? 'start' : 'center';
|
|
4088
|
-
}, devices.mobile, function (_ref3) {
|
|
4089
|
-
var tabsOverflow = _ref3.tabsOverflow
|
|
4090
|
-
|
|
4089
|
+
}, devices.mobileAndTablet, devices.mobile, function (_ref3) {
|
|
4090
|
+
var tabsOverflow = _ref3.tabsOverflow,
|
|
4091
|
+
hasTwoArrows = _ref3.hasTwoArrows;
|
|
4092
|
+
return tabsOverflow && hasTwoArrows ? 'calc(100% - 50px)' : '100%';
|
|
4093
|
+
});
|
|
4094
|
+
var ArrowsContainer = /*#__PURE__*/styled__default.div(_templateObject5$4 || (_templateObject5$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: ", ";\n height: var(--anchor-tabs-height);\n background-color: var(--base-color-white);\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 10px;\n"])), function (_ref4) {
|
|
4095
|
+
var fullWidth = _ref4.fullWidth;
|
|
4096
|
+
return fullWidth ? '74px' : '46px';
|
|
4091
4097
|
});
|
|
4092
|
-
var ArrowsContainer = /*#__PURE__*/styled__default.div(_templateObject5$4 || (_templateObject5$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 74px;\n height: var(--anchor-tabs-height);\n background-color: var(--base-color-white);\n display: flex;\n align-items: center;\n justify-content: flex-end;\n gap: 10px;\n"])));
|
|
4093
4098
|
var ArrowWrapper = /*#__PURE__*/styled__default.div(_templateObject6$4 || (_templateObject6$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n width: 24px;\n height: 24px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: flex-center;\n\n :hover {\n && svg path {\n fill: var(--base-color-primary);\n }\n }\n"])));
|
|
4094
4099
|
|
|
4095
4100
|
var _excluded$7 = ["id", "text"];
|
|
@@ -4116,6 +4121,8 @@ var AnchorTabBar = function AnchorTabBar(_ref) {
|
|
|
4116
4121
|
canScrollToRight = _useState4[0],
|
|
4117
4122
|
setCanScrollToRight = _useState4[1];
|
|
4118
4123
|
|
|
4124
|
+
var hasTwoArrows = canScrollToRight && canScrollToLeft;
|
|
4125
|
+
|
|
4119
4126
|
var isSelectedItem = function isSelectedItem(id) {
|
|
4120
4127
|
return id === selectedItem;
|
|
4121
4128
|
};
|
|
@@ -4128,6 +4135,25 @@ var AnchorTabBar = function AnchorTabBar(_ref) {
|
|
|
4128
4135
|
setSelectedItem(id);
|
|
4129
4136
|
};
|
|
4130
4137
|
|
|
4138
|
+
var getScrollWidth = function getScrollWidth() {
|
|
4139
|
+
var width = 0;
|
|
4140
|
+
var selectedItemIndex = tabs.findIndex(function (el) {
|
|
4141
|
+
return el.id === selectedItem;
|
|
4142
|
+
});
|
|
4143
|
+
var tabLinks = document.getElementsByClassName('anchor-tab-bar-tablink');
|
|
4144
|
+
|
|
4145
|
+
for (var i = 0; i < selectedItemIndex; ++i) {
|
|
4146
|
+
width += tabLinks[i].scrollWidth + LIST_ITEM_GAP;
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
return width;
|
|
4150
|
+
};
|
|
4151
|
+
|
|
4152
|
+
React.useEffect(function () {
|
|
4153
|
+
setTimeout(function () {
|
|
4154
|
+
if (tabListRef.current) tabListRef.current.scrollLeft += getScrollWidth();
|
|
4155
|
+
}, 500);
|
|
4156
|
+
}, []);
|
|
4131
4157
|
React.useEffect(function () {
|
|
4132
4158
|
var _tabListRef$current, _tabListRef$current2;
|
|
4133
4159
|
|
|
@@ -4182,6 +4208,12 @@ var AnchorTabBar = function AnchorTabBar(_ref) {
|
|
|
4182
4208
|
if (tabListRef.current) {
|
|
4183
4209
|
var scroll = tabListRef.current.scrollLeft;
|
|
4184
4210
|
var newScroll = Math.min(tabListRef.current.clientWidth, tabListRef.current.scrollWidth - scroll);
|
|
4211
|
+
|
|
4212
|
+
if (scroll - newScroll < LIST_ITEM_GAP) {
|
|
4213
|
+
tabListRef.current.scrollLeft += newScroll + LIST_ITEM_GAP;
|
|
4214
|
+
return;
|
|
4215
|
+
}
|
|
4216
|
+
|
|
4185
4217
|
tabListRef.current.scrollLeft += newScroll;
|
|
4186
4218
|
}
|
|
4187
4219
|
};
|
|
@@ -4190,6 +4222,12 @@ var AnchorTabBar = function AnchorTabBar(_ref) {
|
|
|
4190
4222
|
if (tabListRef.current) {
|
|
4191
4223
|
var scroll = tabListRef.current.scrollLeft;
|
|
4192
4224
|
var newScroll = Math.max(0, scroll - tabListRef.current.clientWidth);
|
|
4225
|
+
|
|
4226
|
+
if (newScroll < LIST_ITEM_GAP) {
|
|
4227
|
+
tabListRef.current.scrollLeft = newScroll - LIST_ITEM_GAP;
|
|
4228
|
+
return;
|
|
4229
|
+
}
|
|
4230
|
+
|
|
4193
4231
|
tabListRef.current.scrollLeft = newScroll;
|
|
4194
4232
|
}
|
|
4195
4233
|
};
|
|
@@ -4203,8 +4241,8 @@ var AnchorTabBar = function AnchorTabBar(_ref) {
|
|
|
4203
4241
|
_ref3$scrollWidth = _ref3.scrollWidth,
|
|
4204
4242
|
scrollWidth = _ref3$scrollWidth === void 0 ? 0 : _ref3$scrollWidth;
|
|
4205
4243
|
|
|
4206
|
-
setCanScrollToLeft(scrollLeft >
|
|
4207
|
-
setCanScrollToRight(scrollLeft + clientWidth < scrollWidth);
|
|
4244
|
+
setCanScrollToLeft(scrollLeft > LIST_ITEM_GAP);
|
|
4245
|
+
setCanScrollToRight(scrollLeft + clientWidth + LIST_ITEM_GAP < scrollWidth);
|
|
4208
4246
|
};
|
|
4209
4247
|
|
|
4210
4248
|
return /*#__PURE__*/React__default.createElement(AnchorTabbarWrapper, null, /*#__PURE__*/React__default.createElement(TabsGrid, null, /*#__PURE__*/React__default.createElement(GridItem, {
|
|
@@ -4215,6 +4253,7 @@ var AnchorTabBar = function AnchorTabBar(_ref) {
|
|
|
4215
4253
|
}, /*#__PURE__*/React__default.createElement(TabsWrapper, {
|
|
4216
4254
|
"data-testid": "anchor-tabs"
|
|
4217
4255
|
}, /*#__PURE__*/React__default.createElement(TabsList, {
|
|
4256
|
+
hasTwoArrows: hasTwoArrows,
|
|
4218
4257
|
ref: tabListRef,
|
|
4219
4258
|
tabsOverflow: tabsOverflow,
|
|
4220
4259
|
onScroll: onTabsScroll
|
|
@@ -4227,13 +4266,16 @@ var AnchorTabBar = function AnchorTabBar(_ref) {
|
|
|
4227
4266
|
key: id
|
|
4228
4267
|
}, /*#__PURE__*/React__default.createElement(TabLink, Object.assign({
|
|
4229
4268
|
selected: isSelectedItem(id),
|
|
4269
|
+
className: 'anchor-tab-bar-tablink',
|
|
4230
4270
|
id: "tablink-" + id,
|
|
4231
4271
|
onClick: function onClick(e) {
|
|
4232
4272
|
return onClicktab(e, id);
|
|
4233
4273
|
},
|
|
4234
4274
|
tabIndex: 0
|
|
4235
4275
|
}, rest), text));
|
|
4236
|
-
})), tabsOverflow ? /*#__PURE__*/React__default.createElement(ArrowsContainer,
|
|
4276
|
+
})), tabsOverflow ? /*#__PURE__*/React__default.createElement(ArrowsContainer, {
|
|
4277
|
+
fullWidth: hasTwoArrows
|
|
4278
|
+
}, canScrollToLeft ? /*#__PURE__*/React__default.createElement(ArrowWrapper, {
|
|
4237
4279
|
onClick: scrollToLeft
|
|
4238
4280
|
}, /*#__PURE__*/React__default.createElement(Icon, {
|
|
4239
4281
|
iconName: "Arrow",
|