Skip to content

Commit a11960e

Browse files
Merge pull request #379 from infinum/feature/ui-components-docs-update
ES UI components docs updates
2 parents 758285a + 6334add commit a11960e

14 files changed

Lines changed: 203 additions & 253 deletions

website/bun.lock

Lines changed: 15 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
"dependencies": {
3535
"@docusaurus/core": "^3.9.2",
3636
"@docusaurus/preset-classic": "^3.9.2",
37-
"@eightshift/ui-components": "^5.2.0",
37+
"@eightshift/ui-components": "^6.2.0",
3838
"@infinum/docusaurus-theme": "^0.6.0",
39-
"@mdx-js/react": "^3.1.0",
40-
"@wp-playground/client": "^2.0.3",
39+
"@mdx-js/react": "^3.1.1",
40+
"@wp-playground/client": "^2.0.22",
4141
"clsx": "^2.1.1",
4242
"es-text-loader": "file:plugins/es-text-loader",
4343
"prism-react-renderer": "^2.4.1",

website/ui-components/components/component-showcase.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const ComponentShowcase = ({
2020
<div className='es:flex es:font-sans es:css-reset'>
2121
<div
2222
className={clsx(
23-
'es:border es:border-dashed es:border-gray-200 es:p-4 es:rounded-lg esd-space-v es:shrink-0 esd-showcase',
23+
'es:border es:border-dashed es:border-secondary-200 es:p-4 es:rounded-lg esd-space-v es:shrink-0 esd-showcase',
2424
fitWidth ? 'es:w-fit' : 'esd-showcase-w',
2525
className
2626
)}
@@ -29,7 +29,7 @@ export const ComponentShowcase = ({
2929
{typeof children !== 'function' && children}
3030
</div>
3131

32-
<div className='esd-space-v es:ml-3 es:grow'>
32+
<div className='esd-space-v es:pl-4 es:grow'>
3333
{preContent && preContent(data, setData, ref)}
3434
{resettable && (
3535
<Button

website/ui-components/es-ui-components/async-multi-select.mdx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,31 @@ import { demoGetData } from './select-helpers';
1010
<AsyncMultiSelect
1111
value={data}
1212
onChange={setData}
13-
loadOptions={demoGetData}
13+
fetchFunction={demoGetData}
1414
/>
1515
)}
1616
</ComponentShowcase>
1717

18+
## Default data fetching
19+
20+
To define how label, value, subtitle (optional), and icon (optional) are defined in the options, use `getLabel`, `getValue`, `getSubtitle`, `getIcon`.
21+
22+
```jsx
23+
<AsyncMultiSelect
24+
value={value}
25+
onChange={(value) => setValue(value)}
26+
fetchUrl={(searchText) =>
27+
searchText?.length >= 3 ? `http://example-api.com?limit=5&search=${searchText}` : 'http://example-api.com?limit=5'
28+
}
29+
getLabel={(item) => item?.name}
30+
getValue={(item) => item?.id}
31+
/>
32+
```
33+
34+
## Alternate data fetching
35+
36+
Provide a function that fetches data asynchronously and returns it in the format of an array of objects with `label` and `value` properties.
37+
1838
```jsx
1939
const getOptions = async () => {
2040
...
@@ -23,13 +43,13 @@ const getOptions = async () => {
2343
<AsyncMultiSelect
2444
value={value}
2545
onChange={(value) => setValue(value)}
26-
loadOptions={getOptions}
46+
fetchFunction={getOptions}
2747
/>
2848
```
2949
3050
:::note
3151
Props are mostly the same as for the [Single select](/components/es-ui-components/select),
32-
with the exceptions of `options` (which is replaced with `loadOptions`) and `simpleValue`, which is not supported.
52+
with the exceptions of `options` (which is replaced with `fetchFunction`) and `simpleValue`, which is not supported.
3353
:::
3454
3555
For the complete list of props, use your IDE's autocomplete functionality.

website/ui-components/es-ui-components/async-select.mdx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,31 @@ import { demoGetData } from './select-helpers';
1010
<AsyncSelect
1111
value={data}
1212
onChange={setData}
13-
loadOptions={demoGetData}
13+
fetchFunction={demoGetData}
1414
/>
1515
)}
1616
</ComponentShowcase>
1717

18+
## Default data fetching
19+
20+
To define how label, value, subtitle (optional), and icon (optional) are defined in the options, use `getLabel`, `getValue`, `getSubtitle`, `getIcon`.
21+
22+
```jsx
23+
<AsyncSelect
24+
value={value}
25+
onChange={(value) => setValue(value)}
26+
fetchUrl={(searchText) =>
27+
searchText?.length >= 3 ? `http://example-api.com?limit=5&search=${searchText}` : 'http://example-api.com?limit=5'
28+
}
29+
getLabel={(item) => item?.name}
30+
getValue={(item) => item?.id}
31+
/>
32+
```
33+
34+
## Alternate data fetching
35+
36+
Provide a function that fetches data asynchronously and returns it in the format of an array of objects with `label` and `value` properties.
37+
1838
```jsx
1939
const getOptions = async () => {
2040
...
@@ -23,13 +43,13 @@ const getOptions = async () => {
2343
<AsyncSelect
2444
value={value}
2545
onChange={(value) => setValue(value)}
26-
loadOptions={getOptions}
46+
fetchFunction={getOptions}
2747
/>
2848
```
2949
3050
:::note
3151
Props are mostly the same as for the [Single select](/components/es-ui-components/select),
32-
with the exceptions of `options` (which is replaced with `loadOptions`) and `simpleValue`, which is not supported.
52+
with the exceptions of `options` (which is replaced with `fetchFunction`) and `simpleValue`, which is not supported.
3353
:::
3454
3555
For the complete list of props, use your IDE's autocomplete functionality.

website/ui-components/es-ui-components/block-icons.mdx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { ComponentShowcase } from '../components/component-showcase';
44
import { Button, InputField } from '@eightshift/ui-components';
55
import { icons, blockIcons, BlockIcon } from '@eightshift/ui-components/icons';
66

7+
Use within block manifests, or in your UI with the `<BlockIcon />` component.
8+
79
<ComponentShowcase
810
className='es:flex es:flex-wrap es:gap-2 !es:space-y-0 es:w-full'
911
fitWidth
@@ -22,24 +24,25 @@ import { icons, blockIcons, BlockIcon } from '@eightshift/ui-components/icons';
2224
data?.length > 0 ? k.toLowerCase().includes(data?.toLowerCase()) : true
2325
);
2426

25-
if (filteredIcons.length < 1) {
26-
return (
27-
<span>Nothing found</span>
28-
);
29-
}
27+
if (filteredIcons.length < 1) {
28+
return (
29+
<span>Nothing found</span>
30+
);
31+
}
3032

31-
return filteredIcons.map((icon, index) => (
32-
<Button
33-
key={index}
34-
className='esd-icon-showcase-button'
35-
icon={<BlockIcon iconName={icon} />}
36-
tooltip={<span className='es:font-mono'>{icon}</span>}
37-
aria-label={icon}
38-
onPress={() => {
39-
navigator.clipboard.writeText(icon);
40-
}}
41-
/>
42-
));
43-
}}
33+
return filteredIcons.map((icon, index) => (
34+
<Button
35+
key={index}
36+
className='esd-icon-showcase-button'
37+
icon={<BlockIcon iconName={icon} />}
38+
tooltip={<span className='es:font-mono'>{icon}</span>}
39+
aria-label={icon}
40+
onPress={() => {
41+
navigator.clipboard.writeText(icon);
42+
}}
43+
type='simple'
44+
/>
45+
));
46+
}}
4447

4548
</ComponentShowcase>

website/ui-components/es-ui-components/draggable-list-helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const DraggableDemo = ({ data, setData, ...rest }) => {
5959
<Draggable
6060
items={data}
6161
onChange={setData}
62-
className='es:grid es:grid-cols-2'
62+
className='es:grid es:grid-cols-2 es:gap-2'
6363
{...rest}
6464
>
6565
{(item) => {

website/ui-components/es-ui-components/getting-started.mdx

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,60 @@ At the minimum you have to import the main styles, which come in 3 flavors:
1313

1414
1. *For generic usage*
1515
```scss
16-
@import '~@eightshift/ui-components/dist/assets/style.css';
16+
@import '@eightshift/ui-components/dist/assets/style.css';
1717
```
1818
Uses cascade layers to separate styles, includes the default CSS reset.
1919

20-
2. *For the WP Gutenberg editor*
20+
2. *For the WP Gutenberg editor* in legacy projects
2121
```scss
22-
@import '~@eightshift/ui-components/dist/assets/style-editor.css';
22+
@import '@eightshift/ui-components/dist/assets/style-editor.css';
2323
```
2424
Cascade layers are not used, CSS reset is included.
2525

2626
3. *For the WP admin area*
2727
```scss
28-
@import '~@eightshift/ui-components/dist/assets/style-admin.css';
28+
@import '@eightshift/ui-components/dist/assets/style-admin.css';
2929
```
3030
Cascade layers are not used, CSS reset is opt-in using the `es:css-reset` class.
3131

3232
#### Extras
3333
To expand the font coverage to the Block editor (even the Gutenberg components), import:
3434
```scss
35-
@import '~@eightshift/ui-components/dist/assets/wp-font-enhancements.css';
35+
@import '@eightshift/ui-components/dist/assets/wp-overrides/replace-fonts.css';
3636
```
3737

38-
Optionally, import the WordPress UI enhancements, which correct some of the inconsistencies in the default components.
38+
Optionally, import (some or all of) the WordPress UI enhancements, which correct some of the inconsistencies in the default components.
3939

4040
```scss
41-
@import '~@eightshift/ui-components/dist/assets/wp-ui-enhancements.css';
41+
@import '@eightshift/ui-components/dist/assets/wp-overrides/fix-label-text-case.css';
42+
@import '@eightshift/ui-components/dist/assets/wp-overrides/increase-sidebar-width.css';
43+
@import '@eightshift/ui-components/dist/assets/wp-overrides/make-block-messages-nicer.css';
44+
@import '@eightshift/ui-components/dist/assets/wp-overrides/restyle-tooltips.css';
45+
@import '@eightshift/ui-components/dist/assets/wp-overrides/round-corners.css';
46+
@import '@eightshift/ui-components/dist/assets/wp-overrides/unify-button-sizes.css';
47+
@import '@eightshift/ui-components/dist/assets/wp-overrides/allow-full-width-blocks.css';
4248
```
4349

44-
:::caution
4550
If using Frontend libs version 12 or older, skip the WordPress UI enhancements, as they will conflict with the styles included there.
46-
:::
4751

4852
#### Recommended WordPress setup
4953
`application-blocks-editor.css`
5054
```scss
51-
@import '~@eightshift/ui-components/dist/assets/wp-font-enhancements.css';
52-
@import '~@eightshift/ui-components/dist/assets/wp-ui-enhancements.css';
53-
@import '~@eightshift/ui-components/dist/assets/style-editor.css';
55+
@import '@eightshift/ui-components/dist/assets/wp-overrides/replace-fonts.css';
56+
@import '@eightshift/ui-components/dist/assets/wp-overrides/fix-label-text-case.css';
57+
@import '@eightshift/ui-components/dist/assets/wp-overrides/increase-sidebar-width.css';
58+
@import '@eightshift/ui-components/dist/assets/wp-overrides/make-block-messages-nicer.css';
59+
@import '@eightshift/ui-components/dist/assets/wp-overrides/restyle-tooltips.css';
60+
@import '@eightshift/ui-components/dist/assets/wp-overrides/round-corners.css';
61+
@import '@eightshift/ui-components/dist/assets/wp-overrides/unify-button-sizes.css';
62+
@import '@eightshift/ui-components/dist/assets/wp-overrides/allow-full-width-blocks.css';
63+
64+
@import '@eightshift/ui-components/dist/assets/style.css'; // or style-editor.css for non-Tailwind projects
5465
```
5566

5667
`application-admin.css`
5768
```scss
58-
@import '~@eightshift/ui-components/dist/assets/style-admin.css';
69+
@import '@eightshift/ui-components/dist/assets/style-admin.css';
5970
```
6071

6172
### Enjoy!

website/ui-components/es-ui-components/migrations.mdx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,51 @@
11
# Migrations
2+
23
Here's how to upgrade between various versions of ES UI components.
34

5+
## v5.x.x to v6.x.x
6+
7+
1. Update the package to the latest version.
8+
9+
2. Update CSS imports for UI components styles.
10+
11+
Font enhancements:
12+
13+
```diff
14+
- @eightshift/ui-components/dist/assets/wp-font-enhancements.css
15+
+ @eightshift/ui-components/dist/assets/wp-overrides/replace-fonts.css
16+
```
17+
18+
General style tweaks/overrides (now modular, pick&choose enhancements you want):
19+
20+
```diff
21+
- @eightshift/ui-components/dist/assets/wp-ui-enhancements.css
22+
+ @eightshift/ui-components/dist/assets/wp-overrides/fix-label-text-case.css
23+
+ @eightshift/ui-components/dist/assets/wp-overrides/increase-sidebar-width.css
24+
+ @eightshift/ui-components/dist/assets/wp-overrides/make-block-messages-nicer.css
25+
+ @eightshift/ui-components/dist/assets/wp-overrides/restyle-tooltips.css
26+
+ @eightshift/ui-components/dist/assets/wp-overrides/round-corners.css
27+
+ @eightshift/ui-components/dist/assets/wp-overrides/unify-button-sizes.css
28+
+ @eightshift/ui-components/dist/assets/wp-overrides/allow-full-width-blocks.css
29+
```
30+
31+
3. Selects
32+
33+
Check all `Select`, `AsyncSelect`, `MultiSelect`, `AsyncMultiSelect` components, remove any references to legacy `react-select` components (name starting with `RS`)
34+
35+
`AsyncSelect`/`AsyncMultiSelect`: change `loadOptions` prop for `fetchFunction`.
36+
37+
4. `ComponentToggle`
38+
39+
If used, try to replace with a `Toggle` and conditional rendering. The component _is_ marked as deprecated, but won't be removed until v7.
40+
41+
5. Misc. minor updates:
42+
43+
- `ContainerPanel` <br/> Re-add `topBorder` if desired
44+
- `Tabs` <br/> Replace `pillInverse`, `pillCompactInverse`, `pillOutline`, and `pillCompactOutline` styles if used
45+
- `OptionsPanelIntro` <br/> Remove `border` prop if set
46+
- `NumberPicker` <br/> Update values for the `size` prop if set; `'compact' | 'small' | 'default'` &rarr; `'small' | 'medium' | 'default' | 'large'`
47+
- `NumberPicker` <br/> If using `<Button>` as a custom control within, add `slot={null}`
48+
449
## v1.x.x to v2.0.1
550

651
1. Update the package to the latest version.
@@ -14,13 +59,15 @@ Here's how to upgrade between various versions of ES UI components.
1459
2. Replace editor imports
1560

1661
`application-blocks-editor.css`
62+
1763
```diff
1864
@import '~@eightshift/ui-components/dist/assets/wp-font-enhancements.css';
1965
- @import '~@eightshift/ui-components/dist/assets/style.css';
2066
+ @import '~@eightshift/ui-components/dist/assets/style-editor.css';
2167
```
2268

2369
`application-admin.css`
70+
2471
```diff
2572
- @import '~@eightshift/ui-components/dist/assets/style.css';
2673
+ @import '~@eightshift/ui-components/dist/assets/style-admin.css';

0 commit comments

Comments
 (0)