@amboss/design-system 1.0.9 → 1.0.10

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,3 +1,27 @@
1
+ # v1.0.10 (Tue Feb 15 2022)
2
+
3
+ ### Release Notes
4
+
5
+ #### Add CacheProvider and createCache as exports ([#421](https://github.com/amboss-mededu/amboss-design-system/pull/421))
6
+
7
+ Enable emotional DS components to work in the shadow-dom.
8
+ https://github.com/emotion-js/emotion/issues/1366
9
+ https://emotion.sh/docs/cache-provider
10
+ https://stackblitz.com/edit/emotion-shadow-dom-example?file=ShadowDomContainer.js
11
+ https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule
12
+
13
+ ---
14
+
15
+ #### 🐛 Bug Fix
16
+
17
+ - Add CacheProvider and createCache as exports [#421](https://github.com/amboss-mededu/amboss-design-system/pull/421) ([@AlexJeffcott](https://github.com/AlexJeffcott))
18
+
19
+ #### Authors: 1
20
+
21
+ - Alex ([@AlexJeffcott](https://github.com/AlexJeffcott))
22
+
23
+ ---
24
+
1
25
  # v1.0.9 (Fri Feb 11 2022)
2
26
 
3
27
  ### Release Notes
package/README.md CHANGED
@@ -255,3 +255,33 @@ export const Box = styled.div<BoxProps>(
255
255
  );
256
256
  ```
257
257
 
258
+ ## Shadow-DOM
259
+ In order to use emotion-enabled DS components in the shadow-dom, you need to take some steps to 'link' the styles in the light-dom (these are added by emotion using CSSStyleSheet.insertRule() which is why <style data-emotion> appears empty in the DOM).
260
+
261
+ emotion-js/emotion#1366
262
+ https://emotion.sh/docs/cache-provider
263
+ https://stackblitz.com/edit/emotion-shadow-dom-example?file=ShadowDomContainer.js
264
+ https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule
265
+
266
+ ```js
267
+ import { ThemeProvider, light, Card, H1, CacheProvider, createCache } from '@amboss/design-system';
268
+ class SuchShadow extends HTMLElement {
269
+ connectedCallback() {
270
+ const root = document.createElement('div');
271
+ this.attachShadow({ mode: 'open' });
272
+ this.emotionCache = createCache({ container: this.shadowRoot });
273
+ render(
274
+ <ThemeProvider theme={light}>
275
+ <CacheProvider value={this.emotionCache}>
276
+ <Card>
277
+ <H1>I love you shadow unicorn!!!</H1>
278
+ </Card>
279
+ </CacheProvider>
280
+ </ThemeProvider>,
281
+ root
282
+ );
283
+ }
284
+ }
285
+
286
+ customElements.define('shadow-element', SuchShadow);
287
+ ```