@royaloperahouse/harmonic 0.18.7 → 0.18.8

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 CHANGED
@@ -1,7 +1,9 @@
1
+ ## [0.18.8]
2
+ - Accordion and Select2: UI clipping bugfix
3
+
1
4
  ## [0.18.7]
2
5
  - Carousel, Typography, HighlightCarousels added font changed prop
3
6
 
4
-
5
7
  ## [0.18.6]
6
8
  - CastFilter: Add greyscale option to cast filter
7
9
 
package/README.GIT CHANGED
@@ -1,69 +1,293 @@
1
- # Royal Opera House - Harmonic
1
+ # Royal Opera House Harmonic - Front End Design System
2
2
 
3
- Welcome to The Royal Opera House Harmonic library components `@royaloperahouse/harmonic`.
3
+ Welcome to The Royal Opera House Front End Design System, `@royaloperahouse/harmonic`
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
- ## Install
9
+ The NPM packages are published at [Royal Opera House - Harmonic](https://www.npmjs.com/package/@royaloperahouse/harmonic)
10
+
11
+ The Storybook for the latest version of the library is hosted at [Storybook - Harmonic] TODO: S3 deployment
12
+
13
+
14
+ ## Prerequisites
15
+ ---
16
+
17
+ * Make sure the required package dependencies are installed using `yarn install`
18
+ * If this is the first time you are working on Harmonic, make sure to run `yarn build` to build all the modules.
19
+
20
+ * **To deploy the storybook publicly** you will need credentials for the **parent** 'Royal Opera House' AWS account in your `~/.aws/credentials` file.
21
+ * The deploy script expects these to be called `[parent]`.
22
+
23
+ * You can find these values at:
24
+
25
+ *AWS access portal/ Accounts tab -> 'Royal Opera House' -> 'Access keys' -> 'Option 2: Add a profile to your AWS credentials file'*
26
+
27
+ * **To deploy a preview** for demo / QA you will need:
28
+
29
+ * A Chromatic account with a **Developer** role in the `roh-ml` project in Chromatic
30
+ * [Mari Lovell](mari.lovell@roh.org.uk) is the current owner of this project, you can contact her to invite you
31
+ * The `CHROMATIC_PROJECT_TOKEN` -- find this in 1Password or ask the project owner.
32
+
33
+
34
+ * **To enable publishing to the NPM package**:
35
+ * Create account / log in to NPM
36
+ * Ask a colleague with admin rights to be added as a contributer
37
+ * Generate your own ROH `NPM_TOKEN` (store this token in 1Password)
38
+ * Set up Two-Factor Authentication for NPM, as you will be prompted by the publishing script
39
+
40
+
41
+ ## Versioning
42
+ ---
43
+ > NOTE: The following applies while the Harmonic project is in Alpha (before a version 1.0.0 release)
44
+
45
+ We are **not** yet using semantic versioning.
46
+
47
+ When proposing changes to the Harmonic library, increment the patch version (the last number) by one, **only** in the changelog (alternatively, leave the version in the changelog as TBC) along with a note about your changes.
48
+
49
+ Only increment the version in the package.json for releasing snapshots.
50
+
51
+ Once your changes are merged to the main branch and released in a new version, the release manager will be responsible for incrementing that release version.
52
+
53
+ > NOTE: The following **may** apply once the Harmonic project is out of Alpha, but is subject to change before then.
54
+
55
+ We use [Semantic Versioning](https://semver.org/) for Harmonic.
56
+
57
+ Given a version number MAJOR.MINOR.PATCH, increment the:
58
+
59
+ * MAJOR version when you make incompatible library changes
60
+ * MINOR version when you add functionality in a backwards compatible manner
61
+ * PATCH version when you make backwards compatible bug fixes
62
+
63
+ When you create a new release always update the `CHANGELOG` and `package.json`
64
+
65
+ Increment your version from the latest stable version on [Royal Opera House - Harmonic](https://www.npmjs.com/package/@royaloperahouse/harmonic?activeTab=versions)
66
+
67
+
68
+ ## Deploying the Storybook
69
+ ---
70
+
71
+ ### **1. To build and deploy locally**
72
+
73
+ You can quickly build and serve the contents of `/storybook-static` from your local machine, for development and manual testing. To do this run:
74
+
75
+ ```bash
76
+ yarn storybook
77
+ ```
78
+
79
+ By default the storybook will be accessible at
80
+ [http://localhost:6006/]()
81
+
82
+ The server will hot-reload on most changes.
83
+
84
+ ### **2. To deploy a preview version remotely**
85
+
86
+ You can deploy a release candidate, or work-in-progress to [Chromatic](https://www.chromatic.com/) for showcase or QA.
87
+
88
+ **NOTE:** you will need the `CHROMATIC_PROJECT_TOKEN` and to be invited as a contributor to the Harmonic project in Chromatic, as described in *Prerequisites* above.
89
+
90
+ Either set the token as a shell variable or use a `.env` file in the `harmonic` root directory containing the token, as so:
91
+
92
+ ```
93
+ CHROMATIC_PROJECT_TOKEN=tokengoeshere
94
+ ```
95
+
96
+ Run:
97
+ ```
98
+ CHROMATIC_PROJECT_TOKEN=tokengoeshere yarn deploy-storybook-dev
99
+ ```
100
+
101
+ to build and deploy the storybook from your repo to Chromatic.
102
+
103
+ You will find the address of your deployed storybook in the console output, looking something like this:
104
+
105
+ `→ View your Storybook at https://randomHexString-randomAlphabeticalString.chromatic.com`
106
+
107
+ ### **3. To deploy a release version**
108
+
109
+ You can deploy the contents of `./storybook-static` to S3 as a static site, which is permanently accessible at [WIP] TODO: S3 deployment
110
+
111
+ **NOTE:** To do this you will need the correct `AWS` credentials set up, as described in *Prerequisites* above.
112
+
113
+ First build the storybook using:
114
+
115
+ ```
116
+ yarn build-storybook
117
+ ```
118
+
119
+ then run:
120
+
121
+ ```bash
122
+ yarn deploy-storybook
123
+ ```
124
+
125
+ > **IMPORTANT:** This URL is intended to showcase the latest stable version of Harmonic, it should be kept up to date with the `main` Harmonic 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*.
126
+
127
+
128
+ ## Releasing a New Package Version
129
+ ---
130
+
131
+ This is the procedure for releasing a new Harmonic NPM package.
132
+
133
+ There are two types of package:
134
+
135
+ A **snapshot** can be published to use a development version of the Harmonic library in our frontend staging environments, to perform integrated, manual testing.
136
+
137
+ A **stable** package is published for use in production.
138
+
139
+ **NOTE:** You will need the `NPM_TOKEN`, as described in 'Prerequisites' above.
140
+
141
+ ### **1. To release a snapshot version**
142
+
143
+ > **IMPORTANT:** Make sure you always publish your **snapshots** from `development` after merging in your feature branch.
144
+
145
+ For snapshots, `RELEASE_VERSION` should be the same as the latest **stable** version of the Harmonic Library, as found in [npm Harmonic - Versions](https://www.npmjs.com/package/@royaloperahouse/harmonic?activeTab=versions), followed by an **unused** lowercase letter.
146
+
147
+ 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`
148
+
149
+ To publish a snapshot use:
9
150
 
10
151
  ```bash
11
- npm i --save @royaloperahouse/harmonic
152
+ NPM_ROH_TOKEN={NPM_TOKEN} RELEASE_VERSION={RELEASE_VERSION} yarn publish-snapshot
12
153
  ```
154
+ Use the version name to install the package in a frontend repo.
155
+
156
+ ### **2. To release a stable version**
157
+
158
+ > **IMPORTANT:** Make sure you always publish your **stable** packages from `main` after merging in your feature branch.
159
+
160
+ For stable releases, increment your version from the latest **stable** version found on [npm Harmonic - Versions](https://www.npmjs.com/package/@royaloperahouse/harmonic?activeTab=versions), 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`!)
161
+
162
+ To publish a stable package use:
163
+
13
164
  ```bash
14
- yarn add @royaloperahouse/harmonic
165
+ NPM_ROH_TOKEN={NPM_TOKEN} RELEASE_VERSION={RELEASE_VERSION} yarn publish-release
15
166
  ```
16
167
 
17
- ## Usage
18
168
 
19
- ```javascript
20
- import {
21
- Footer, GlobalStyles, ThemeProvider, ThemeType,
22
- } from '@royaloperahouse/harmonic';
169
+ ## Using the Package
170
+ ---
171
+
172
+ The package is deployed to NPM, and can be installed using yarn or npm:
23
173
 
174
+ ```bash
175
+ npm i --save @royaloperahouse/harmonic
24
176
  ```
25
- ## Sample
177
+ ```bash
178
+ yarn add @royaloperahouse/harmonic
179
+ ```
180
+
26
181
 
27
- ```javascript
182
+ ## Testing
183
+ ---
28
184
 
29
- import {
30
- Footer, GlobalStyles, ThemeProvider, ThemeType,
31
- } from '@royaloperahouse/harmonic';
185
+ To **Lint** the package use:
32
186
 
187
+ ```bash
188
+ yarn lint
189
+ # Use the --fix option to perform automatic fixes
190
+ ```
33
191
 
34
- const App = ({ children }: InnerProps): React.ReactElement => (
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
- );
192
+ To run the **unit tests** (using Jest) use:
53
193
 
194
+ ```bash
195
+ yarn test
196
+
197
+ # Use the -u option to update snapshots if needed
198
+ # Run `yarn test:watch` to re-run tests on changes
54
199
  ```
55
200
 
56
- ## Components
57
- (Complete)
58
- ControlledDropdown, ImageProportion, Typography (Display, Header, Subtitle,BodyCopy, Overline, ButtonText, Caption, NavigationText, TextLink)
201
+ To **run and and store the unit tests** for display in storybook use:
202
+
203
+ ```bash
204
+ yarn test-storybook
205
+ # Use the -u option to update snapshots if needed
206
+ ```
207
+
208
+
209
+ ## Development Process
210
+ ---
211
+
212
+ ### **1. Branching Model**
213
+ * The Harmonic project lives in the `harmonic-library/harmonic` *repository*
214
+ * When working on Harmonic, treat the `harmonic` directory as your root
215
+ * The Harmonic **development** branch is for QA
216
+ * The Harmonic **main** branch is currently for stable releases
217
+ * All work should be done on a correctly named **feature branch** of the format: `issueType/ticketNumber-short-description-of-feature`, e.g. `feature/RD-12345-add-example-component`
218
+ * Always create your feature branch FROM, and submit pull requests TO, the **main** branch
219
+ * For **QA / UAT** of a Harmonic component in isolation: following review you should deploy a preview version to Chromatic straight from your **feature branch** _without_ merging to development
220
+ * For releasing an **NPM snapshot**: merge your feature branch into the **development** branch and publish the NPM snapshot from there
221
+
222
+ ### **2. Detailed Workflow**
223
+
224
+ #### **Before review:**
225
+
226
+ * Git pull the latest version of Harmonic from `main`
227
+ * Checkout a new, correctly-named feature branch from `main`
228
+ * Do your work on this feature branch
229
+ * Run: `yarn lint --fix`
230
+ * Run: `yarn test -u`
231
+ * Commit your changes
232
+ * Create a pull request from your feature branch to `main`
233
+ * Add the appropriate reviewers
234
+
235
+ #### **Before QA / UAT:**
236
+
237
+ After your PR is approved, you have two options:
238
+
239
+ **i.** For QA of a component in isolation:
240
+
241
+ * Follow the steps above in *Deploying the Storybook -> 2. Deploying a preview version remotely*
242
+ * Share the generated Chromatic URL with the appropriate people for QA / UAT
243
+
244
+ **ii.** For integrated testing of a component in the frontend staging environments:
245
+
246
+ * Check out the `development` branch
247
+ * Merge your work in to `development`
248
+ * Follow the steps above under *Publishing a New Package Version -> 1. To release a snapshot version*
249
+ * Git push the updated `development` branch to remote
250
+ * Finally, in the frontend repo:
251
+
252
+ 1. Update the `package.json` to reference the new snapshot version
253
+ 2. Run: `yarn install`
254
+ 3. Deploy the frontend to a staging environment
255
+
256
+ #### **When ready for production:**
257
+
258
+ * Return to your Harmonic **feature branch**
259
+ * Update the HArmonic version in `package.json`, incrementing from the last **stable** release, found in [npm Harmonic - Versions](https://www.npmjs.com/package/@royaloperahouse/harmonic?activeTab=versions), and following the rules described in the *Versioning* section
260
+ * Update `CHANGELOG.md`, adding the new version number and a short description of your changes
261
+ * Run: `yarn lint --fix`
262
+ * Run: `yarn test -u`
263
+ * Run: `yarn test-storybook -u`
264
+ * Run: `yarn build-storybook`
265
+ * Git commit, push, and update your PR for final approval
266
+ * Merge your approved PR to `main`
267
+ * Follow the steps in *Publishing a New Package Version -> 2. To release a stable version* to publish the NPM package
268
+ * Finally, follow the steps in *Deploying The Storybook -> 3. To deploy a release version*, to update the public Harmonic Storybook page
269
+
270
+ 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.
271
+
272
+
273
+ ## Notes
274
+ ---
275
+ ### The `storybook-static` folder
276
+
277
+ 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:
278
+
279
+ ```bash
280
+ yarn build-storybook
281
+ ```
59
282
 
60
- (WIP)
61
- Colors, Footer, Iconography, Navigation, Tab, Tabs, TabLink
283
+ 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.
62
284
 
63
- (TODO / Legacy)
64
- Accordion, Accordions, AltHeader, AnchorTabBar, AnnouncementBanner, Card, Cards, Carousel, CinemaBadge, ContactCard, devices, Editorial, GlobalStyles, Grid, GridItem, HighlightsCarousel, HighlightsCarouselCinema, HighlightsCarouselCore, HighlightsCarouselStream, ImageWithCaption, PageHeadingCinema, PageHeadingCore, PageHeadingImpact, PageHeadingStream, PeopleListing, PrimaryButton, PromoWithTags, PromoWithTitle, RotatorButtons, SecondaryButton, SecondaryLogo, SectionSplitter, SectionTitle, Sponsorship, StickyBar, StreamBadge, TertiaryButton, TextOnly, Tickbox, TitleWithCTA, ThemeProvider, TypeTags, Quote
285
+ ---
286
+ ### Examples
65
287
 
288
+ 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.
66
289
 
67
- ## Documentation
290
+ ---
291
+ ### Bundle analysis
68
292
 
69
- [See Storybook as a reference] TODO: S3 deployment
293
+ 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`.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Royal Opera House - Harmonic
2
+
3
+ Welcome to The Royal Opera House Harmonic library components `@royaloperahouse/harmonic`.
4
+
5
+ This package is a library of UI components intended to be used in the ROH website.
6
+
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm i --save @royaloperahouse/harmonic
12
+ ```
13
+ ```bash
14
+ yarn add @royaloperahouse/harmonic
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```javascript
20
+ import {
21
+ Footer, GlobalStyles, ThemeProvider, ThemeType,
22
+ } from '@royaloperahouse/harmonic';
23
+
24
+ ```
25
+ ## Sample
26
+
27
+ ```javascript
28
+
29
+ import {
30
+ Footer, GlobalStyles, ThemeProvider, ThemeType,
31
+ } from '@royaloperahouse/harmonic';
32
+
33
+
34
+ const App = ({ children }: InnerProps): React.ReactElement => (
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
+ );
53
+
54
+ ```
55
+
56
+ ## Components
57
+ (Complete)
58
+ ControlledDropdown, ImageProportion, Typography (Display, Header, Subtitle,BodyCopy, Overline, ButtonText, Caption, NavigationText, TextLink)
59
+
60
+ (WIP)
61
+ Colors, Footer, Iconography, Navigation, Tab, Tabs, TabLink
62
+
63
+ (TODO / Legacy)
64
+ Accordion, Accordions, AltHeader, AnchorTabBar, AnnouncementBanner, Card, Cards, Carousel, CinemaBadge, ContactCard, devices, Editorial, GlobalStyles, Grid, GridItem, HighlightsCarousel, HighlightsCarouselCinema, HighlightsCarouselCore, HighlightsCarouselStream, ImageWithCaption, PageHeadingCinema, PageHeadingCore, PageHeadingImpact, PageHeadingStream, PeopleListing, PrimaryButton, PromoWithTags, PromoWithTitle, RotatorButtons, SecondaryButton, SecondaryLogo, SectionSplitter, SectionTitle, Sponsorship, StickyBar, StreamBadge, TertiaryButton, TextOnly, Tickbox, TitleWithCTA, ThemeProvider, TypeTags, Quote
65
+
66
+
67
+ ## Documentation
68
+
69
+ [See Storybook as a reference] TODO: S3 deployment
@@ -5913,7 +5913,7 @@ var SearchBar = function SearchBar(_ref) {
5913
5913
  };
5914
5914
 
5915
5915
  var _templateObject$D, _templateObject2$t, _templateObject3$j, _templateObject4$g, _templateObject5$c, _templateObject6$8, _templateObject7$5;
5916
- var AccordionContainer = /*#__PURE__*/styled__default.div(_templateObject$D || (_templateObject$D = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n div {\n overflow: hidden;\n }\n border-top: 2px solid var(--color-base-light-grey);\n border-bottom: ", ";\n"])), function (_ref) {
5916
+ var AccordionContainer = /*#__PURE__*/styled__default.div(_templateObject$D || (_templateObject$D = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n border-top: 2px solid var(--color-base-light-grey);\n border-bottom: ", ";\n"])), function (_ref) {
5917
5917
  var showLine = _ref.showLine;
5918
5918
  return showLine ? '2px solid var(--color-base-light-grey)' : 'none';
5919
5919
  });
@@ -5937,13 +5937,31 @@ var ContentContainer = /*#__PURE__*/styled__default(ExtendedBodyCopyHarmonic).wi
5937
5937
  shouldForwardProp: function shouldForwardProp(prop) {
5938
5938
  return prop !== 'textHeight';
5939
5939
  }
5940
- })(_templateObject6$8 || (_templateObject6$8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n max-height: ", ";\n\n @media print {\n max-height: max-content;\n }\n\n & em {\n font-family: var(--font-family-body-italics);\n }\n\n & u {\n font-size: var(--font-size-body-1);\n font-family: var(--font-family-body);\n }\n\n @media ", " {\n transition: 100% 0.2s ease;\n }\n"])), function (_ref6) {
5940
+ })(_templateObject6$8 || (_templateObject6$8 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n max-height: ", ";\n overflow: ", ";\n margin-bottom: ", ";\n\n @media print {\n max-height: max-content;\n }\n\n & em {\n font-family: var(--font-family-body-italics);\n }\n\n & u {\n font-size: var(--font-size-body-1);\n font-family: var(--font-family-body);\n }\n\n @media ", " {\n transition: 100% 0.2s ease;\n }\n"])), function (_ref6) {
5941
5941
  var textHeight = _ref6.textHeight;
5942
5942
  return textHeight;
5943
+ }, function (_ref7) {
5944
+ var textHeight = _ref7.textHeight;
5945
+ return textHeight === '0px' ? 'hidden' : 'visible';
5946
+ }, function (_ref8) {
5947
+ var textHeight = _ref8.textHeight;
5948
+ return textHeight === '0px' ? '0px' : '12px';
5943
5949
  }, devices.mobile);
5944
5950
  var PrintHideWrapper = /*#__PURE__*/styled__default.div(_templateObject7$5 || (_templateObject7$5 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n @media print {\n display: none;\n }\n"])));
5945
5951
 
5946
5952
  /* eslint-disable react/no-unstable-nested-components */
5953
+ /** In-flow height only so absolutely positioned UI (e.g. react-select menu) does not inflate scrollHeight. */
5954
+ function getPanelContentHeight(panel) {
5955
+ var inner = panel.firstElementChild;
5956
+ if (!inner || !(inner instanceof HTMLElement)) {
5957
+ return panel.scrollHeight;
5958
+ }
5959
+ var innerStyle = window.getComputedStyle(inner);
5960
+ var marginY = (parseFloat(innerStyle.marginTop) || 0) + (parseFloat(innerStyle.marginBottom) || 0);
5961
+ var panelStyle = window.getComputedStyle(panel);
5962
+ var paddingY = (parseFloat(panelStyle.paddingTop) || 0) + (parseFloat(panelStyle.paddingBottom) || 0);
5963
+ return inner.offsetHeight + marginY + paddingY;
5964
+ }
5947
5965
  var Accordion = function Accordion(_ref) {
5948
5966
  var _expandedStateIcon$ic, _collapsedStateIcon$i;
5949
5967
  var _ref$title = _ref.title,
@@ -5984,7 +6002,7 @@ var Accordion = function Accordion(_ref) {
5984
6002
  var intervalRef = React.useRef(null);
5985
6003
  React.useEffect(function () {
5986
6004
  if (content.current && initOpen) {
5987
- setTextHeight(content.current.scrollHeight + "px");
6005
+ setTextHeight(getPanelContentHeight(content.current) + "px");
5988
6006
  }
5989
6007
  }, [initOpen]);
5990
6008
  React.useEffect(function () {
@@ -6010,7 +6028,7 @@ var Accordion = function Accordion(_ref) {
6010
6028
  return cleanup;
6011
6029
  }
6012
6030
  var updateHeight = function updateHeight() {
6013
- setTextHeight(el.scrollHeight + "px");
6031
+ setTextHeight(getPanelContentHeight(el) + "px");
6014
6032
  };
6015
6033
  rafRef.current = window.requestAnimationFrame(updateHeight);
6016
6034
  if (typeof ResizeObserver !== 'undefined') {