Skip to content

Commit 72eaa16

Browse files
committed
!refactor(renderer): rename renderStaticStyles to renderGlobalStyles
1 parent 5fd6d84 commit 72eaa16

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

lib/create-theme-renderer.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,17 @@ export const createThemeRenderer = (options = {}) => {
8484
const render = () => renderToDom(renderer);
8585

8686
/**
87-
* Renders static styles (e.g. global CSS)
87+
* Renders global styles
8888
*
8989
* Simplified when https://github.com/robinweser/fela/issues/876 is resolved
90-
* @param {StyleObject} initialStaticStyles
90+
* @param {StyleObject} initialGlobalStyles
9191
* @returns {void}
9292
*/
93-
const renderStaticStyles = (initialStaticStyles) => {
94-
const staticStyles = enableCssVariables
95-
? merge({':root': cssVariables})(initialStaticStyles)
96-
: initialStaticStyles;
97-
for (const [selector, style] of Object.entries(staticStyles)) {
93+
const renderGlobalStyles = (initialGlobalStyles) => {
94+
const globalStyles = enableCssVariables
95+
? merge({':root': cssVariables})(initialGlobalStyles)
96+
: initialGlobalStyles;
97+
for (const [selector, style] of Object.entries(globalStyles)) {
9898
/** @type {StyleObject} */
9999
const processedStyle = plugins.reduce(
100100
(_acc, plugin) => plugin(style, 'STATIC', renderer, {theme}),
@@ -121,7 +121,7 @@ export const createThemeRenderer = (options = {}) => {
121121
return {
122122
clear: renderer.clear,
123123
render,
124-
renderStaticStyles,
124+
renderGlobalStyles,
125125
renderStyle,
126126
_subscribe: renderer.subscribe,
127127
};

readme.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ To further explore uinix-theme, visit the [Theme Playground] for interactive dem
3232
- [Create a theme](#create-a-theme)
3333
- [Create a theme renderer](#create-a-theme-renderer)
3434
- [Render themed styles](#render-themed-styles)
35-
- [Render themed static styles](#render-themed-static-styles)
35+
- [Render themed global styles](#render-themed-global-styles)
3636
- [Render themed CSS keyframes](#render-themed-css-keyframes)
3737
- [Configure and render themed atomic CSS](#configure-and-render-themed-atomic-css)
3838
- [Configure and render themed CSS variables](#configure-and-render-themed-css-variables)
@@ -269,12 +269,12 @@ Yields the following rendered CSS:
269269

270270
> **Note:** Please refer to the examples of *style* and *themed style* in the [§ Glossary](#glossary) for details on authoring CSS-in-JS styles and how the themed styles are resolved by the *theme renderer* using the provided *theme* and *theme spec*.
271271
272-
### Render themed static styles
272+
### Render themed global styles
273273

274-
You can render themed *static styles* to the global CSS styles with `renderer.renderStaticStyles`:
274+
You can render themed *global styles* with `renderer.renderGlobalStyles`:
275275

276276
```js
277-
const style = {
277+
const globalStyles = {
278278
body: {
279279
color: 'brand.primary',
280280
padding: 'm',
@@ -288,7 +288,7 @@ const style = {
288288
},
289289
};
290290

291-
renderer.renderStaticStyles(style);
291+
renderer.renderGlobalStyles(globalStyles);
292292
```
293293

294294
Yields the following global CSS styles:
@@ -425,9 +425,9 @@ const renderer = createThemeRenderer({
425425

426426
renderer.render();
427427

428-
const staticStyles = {...}; // your other global styles
428+
const globalStyles = {...}; // your other global styles
429429

430-
renderer.renderStaticStyles(staticStyles);
430+
renderer.renderGlobalStyles(globalStyles);
431431
```
432432

433433
Yields the following rendered global CSS:
@@ -739,7 +739,7 @@ Enables rendering styles as *atomic CSS*.
739739
###### `options.enableCssVariables` (`boolean`, optional, default: `false`)
740740

741741
When enabled, will support *CSS variables* features in the `renderer` methods:
742-
- `renderer.renderStaticStyles` will now render the `theme` as *CSS variables* under the `:root` pseudo class.
742+
- `renderer.renderGlobalStyles` will now render the `theme` as *CSS variables* under the `:root` pseudo class.
743743
- `renderer.renderStyle` will now resolve *themed styles* into its corresponding *CSS variables*.
744744

745745
###### `options.namespace` (`string`, optional, default: `''`)
@@ -771,7 +771,7 @@ Returns a *theme renderer* with methods to resolve and render *themed styles* to
771771
- `renderer.clear()`: Clears and removes all rendered CSS.
772772
- `renderer.render()`: Initializes the renderer.
773773
- `renderer.renderStyle(style, props?)`: Resolves and renders the provided *style object* or *style rule*). Accepts optional *style props*.
774-
- `renderer.renderStaticStyles(style)`: Resolves and renders the provided *static style* object.
774+
- `renderer.renderGlobalStyles(style)`: Resolves and renders the provided *global styles* object.
775775

776776
<details>
777777
<summary>Example</summary>
@@ -802,16 +802,16 @@ Initialize the renderer in a single entry point in your code with:
802802
renderer.render();
803803
```
804804

805-
Render *static styles* to the global CSS with:
805+
Render *global styles* with:
806806

807807
```js
808-
const staticStyles = {
808+
const globalStyles = {
809809
'body': {...}
810810
'*': {...},
811811
'.vendor-classname': {...}
812812
};
813813

814-
renderer.renderStaticStyles(staticStyles);
814+
renderer.renderGlobalStyles(globalStyles);
815815
```
816816

817817
Render either *style objects* or *style rules* with:
@@ -1046,12 +1046,12 @@ The CSS-in-JS syntax is fairly ubiquitous across CSS frameworks and we provide a
10461046
```
10471047
</details>
10481048
- ***Style props***: an object used as an argument for a *style rule*.
1049-
- ***Static style***: refers to static *style objects* that are usually defined once and rendered to the global style sheet.
1049+
- ***Global styles***: refers to global *style objects* that are usually defined once and rendered to the global style sheet.
10501050
<details>
10511051
<summary>Example</summary>
10521052

10531053
```js
1054-
const staticStyles = {
1054+
const globalStyles = {
10551055
'*': {
10561056
boxSizing: 'border-box',
10571057
},

test/create-theme-renderer.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from 'node:assert';
22
import test from 'node:test';
33

44
import {createThemeRenderer} from '../index.js';
5-
import {resolveRenderStaticStyles, resolveRenderStyle} from './util.js';
5+
import {resolveRenderGlobalStyles, resolveRenderStyle} from './util.js';
66

77
test('createThemeRenderer', async (t) => {
88
await t.test('renderer.render', (t) => {
@@ -13,10 +13,10 @@ test('createThemeRenderer', async (t) => {
1313
});
1414
});
1515

16-
await t.test('renderer.renderStaticStyles', async (t) => {
17-
await t.test('should render static style', () => {
16+
await t.test('renderer.renderGlobalStyles', async (t) => {
17+
await t.test('should render global styles', () => {
1818
assert.deepEqual(
19-
resolveRenderStaticStyles({
19+
resolveRenderGlobalStyles({
2020
html: {
2121
color: 'white',
2222
},
@@ -47,9 +47,9 @@ test('createThemeRenderer', async (t) => {
4747
);
4848
});
4949

50-
await t.test('should render themed static style', () => {
50+
await t.test('should render themed global styles', () => {
5151
assert.deepEqual(
52-
resolveRenderStaticStyles(
52+
resolveRenderGlobalStyles(
5353
{
5454
'a:hover': {
5555
color: 'brand.primary',
@@ -79,9 +79,9 @@ test('createThemeRenderer', async (t) => {
7979
});
8080

8181
// Inverted when https://github.com/robinweser/fela/issues/876 is resolved
82-
await t.test('should NOT render responsive static style', () => {
82+
await t.test('should NOT render responsive global styles', () => {
8383
assert.deepEqual(
84-
resolveRenderStaticStyles(
84+
resolveRenderGlobalStyles(
8585
{
8686
'a:hover': {
8787
color: ['red', 'green', 'blue'],
@@ -104,7 +104,7 @@ test('createThemeRenderer', async (t) => {
104104

105105
await t.test('should render theme as css variables under `:root`', () => {
106106
assert.deepEqual(
107-
resolveRenderStaticStyles(
107+
resolveRenderGlobalStyles(
108108
{},
109109
{
110110
enableCssVariables: true,
@@ -149,7 +149,7 @@ test('createThemeRenderer', async (t) => {
149149
'should render theme as css variables under `:root` prefixed with provided namespace',
150150
() => {
151151
assert.deepEqual(
152-
resolveRenderStaticStyles(
152+
resolveRenderGlobalStyles(
153153
{},
154154
{
155155
enableCssVariables: true,
@@ -182,10 +182,10 @@ test('createThemeRenderer', async (t) => {
182182
);
183183

184184
await t.test(
185-
'should evaluate static styles as css variables if enabled',
185+
'should evaluate global styles as css variables if enabled',
186186
() => {
187187
assert.deepEqual(
188-
resolveRenderStaticStyles(
188+
resolveRenderGlobalStyles(
189189
{
190190
a: {
191191
color: 'brand.primary',
@@ -228,10 +228,10 @@ test('createThemeRenderer', async (t) => {
228228
);
229229

230230
await t.test(
231-
'should merge css variables under :root with other static styles',
231+
'should merge css variables under :root with other global styles',
232232
() => {
233233
assert.deepEqual(
234-
resolveRenderStaticStyles(
234+
resolveRenderGlobalStyles(
235235
{
236236
':root': {
237237
'--custom-css-var': '8px',

test/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {filterEntries} from 'uinix-fp';
22

33
import {createThemeRenderer} from '../index.js';
44

5-
export const resolveRenderStaticStyles = (staticStyles, options = {}) => {
5+
export const resolveRenderGlobalStyles = (globalStyles, options = {}) => {
66
const renderer = createThemeRenderer(options);
77

88
const actual = [];
@@ -15,7 +15,7 @@ export const resolveRenderStaticStyles = (staticStyles, options = {}) => {
1515
};
1616

1717
const subscription = renderer._subscribe(listener);
18-
renderer.renderStaticStyles(staticStyles);
18+
renderer.renderGlobalStyles(globalStyles);
1919
subscription.unsubscribe();
2020

2121
return actual;

0 commit comments

Comments
 (0)