Skip to content

Commit b2942f8

Browse files
authored
fix: remove CSS @layer rule from static CSS bundle (#6430)
1 parent 4bcf334 commit b2942f8

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

config/merge-css-modules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ for (const cssModule of cssModules) {
2020
const componentName = basename(cssModule, '.module.css');
2121

2222
fileContent.push(`/* ${componentName} */`);
23-
fileContent.push(cssContent);
23+
fileContent.push(cssContent.replace('@layer ui5-webcomponents-react{', '').replace(/}$/, ''));
2424
fileContent.push('');
2525
}
2626

config/postcss-config-factory.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ export function postcssConfigFactory(packageName) {
1515
cssLayersPlugin(),
1616
postcssModules({
1717
// generateScopedName: '[name]__[local]___[hash:base64:5]',
18-
generateScopedName: function (name, filename, css) {
19-
const file = path.basename(filename, '.module.css');
20-
const i = css.indexOf(`.${name}`);
21-
const lineNumber = css.substring(0, i).split(/[\r\n]/).length;
22-
const hash = stringHash(css).toString(36).substring(0, 5);
23-
24-
return `${file}_${name}_${hash}_${lineNumber}`;
25-
},
2618
getJSON: (cssFileName, json) => {
2719
return null;
2820
},

docs/knowledge-base/Styling.mdx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ This would then be the result:
105105

106106
## Applying styling via `className` or `style`
107107

108-
Almost all components allow setting `className` or `style` to style the component. For web components, this does **not** mean that styles are inherited by shadow root elements per default.
108+
Almost all components allow setting `className` or `style` for custom styling. For standard elements like `div`, `span`, etc., you can easily override internal CSS properties and values, as our styles are encapsulated in a [CSS layer](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer).
109+
For web components, this does **not** mean that styles are inherited by shadow root elements per default.
109110
Only [inherited CSS properties](https://developer.mozilla.org/en-US/docs/Web/CSS/inheritance#inherited_properties) that are not set inside the shadow root or internally passed properties will change the styles of the internal elements.
110111
Another special case are abstract components like the `SuggestionItem`. The `ui5-suggestion-item` element is mainly there to pass props to the actual component inside the shadow root and is therefore not stylable.
111112

@@ -114,6 +115,8 @@ Another special case are abstract components like the `SuggestionItem`. The `ui5
114115
By default, the `ThemeProvider` injects the CSS of the components during runtime. If you want to import the CSS bundles explicitly, you can set the `staticCssInjected` prop to `true`.
115116
This approach provides you with control over the order in which CSS files are injected, making it easier to override styles.
116117

118+
Please note that the static CSS is not wrapped inside a [CSS layer](https://developer.mozilla.org/en-US/docs/Web/CSS/@layer). You can use the [`@import` CSS at-rule](https://developer.mozilla.org/en-US/docs/Web/CSS/@import) to achieve that.
119+
117120
- **main** package import: `import '@ui5/webcomponents-react/styles.css'`
118121
- **charts** package import: `import '@ui5/webcomponents-react-charts/styles.css'`
119122

0 commit comments

Comments
 (0)