Skip to content

Commit 81283e7

Browse files
authored
Merge pull request #1113 from strapi/release/1.8.0
2 parents b432fe3 + 32e0e0b commit 81283e7

File tree

86 files changed

+3550
-2561
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3550
-2561
lines changed

README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@ $ npm i react react-dom @strapi/design-system @strapi/icons styled-components re
3030

3131
## Getting Started
3232

33-
Wrap your application with the `ThemeProvider` and pass the default `lightTheme` or `darkTheme` provided by `@strapi/design-system`.
33+
Wrap your application with the `DesignSystemProvider`. You can additionally pass a theme and/or locale, although you don't have to as we have default values for both.
3434

3535
```jsx
36-
import { ThemeProvider, lightTheme } from '@strapi/design-system';
36+
import { DesignSystemProvider, lightTheme } from '@strapi/design-system';
3737

3838
function MyApp({ children }) {
39-
return <ThemeProvider theme={lightTheme}>{children}</ThemeProvider>;
39+
return (
40+
<DesignSystemProvider locale="en-GB" theme={lightTheme}>
41+
{children}
42+
</DesignSystemProvider>
43+
);
4044
}
4145

4246
export default App;

docs/.storybook/components/Theme.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useState } from 'react';
22
import { useDarkMode } from 'storybook-dark-mode';
33
import { parse } from 'qs';
4-
import { ThemeProvider, Box, lightTheme, darkTheme } from '@strapi/design-system';
4+
import { DesignSystemProvider, Box, lightTheme, darkTheme } from '@strapi/design-system';
55

66
const themeQueryURL = parse(document.location.search).theme;
77

@@ -16,11 +16,11 @@ const Theme = ({ children }) => {
1616
}, [isDarkAddon, isDark]);
1717

1818
return (
19-
<ThemeProvider theme={isDark ? darkTheme : lightTheme}>
19+
<DesignSystemProvider locale="en" theme={isDark ? darkTheme : lightTheme}>
2020
<Box padding={2} background="neutral0">
2121
{children}
2222
</Box>
23-
</ThemeProvider>
23+
</DesignSystemProvider>
2424
);
2525
};
2626

docs/components/DeprecationNotice.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import * as React from 'react';
22
import PropTypes from 'prop-types';
33

4-
import { Flex, Typography, ThemeProvider, lightTheme } from '@strapi/design-system';
4+
import { Flex, Typography, DesignSystemProvider, lightTheme } from '@strapi/design-system';
55

66
export const DeprecationNotice = ({ children, href }) => (
7-
<ThemeProvider theme={lightTheme}>
7+
<DesignSystemProvider theme={lightTheme}>
88
<Flex padding={5} background="danger200" justifyContent="center" marginTop={4} marginBottom={4}>
99
<Typography fontSize={4} fontWeight="bold" as="p">
1010
⛔️
@@ -18,7 +18,7 @@ export const DeprecationNotice = ({ children, href }) => (
1818
⛔️
1919
</Typography>
2020
</Flex>
21-
</ThemeProvider>
21+
</DesignSystemProvider>
2222
);
2323

2424
DeprecationNotice.propTypes = {

docs/stories/Combobox.stories.mdx

+89-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { useState, useEffect } from 'react';
22
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
3-
import { Combobox, CreatableCombobox, ComboboxOption } from '@strapi/design-system';
3+
import {
4+
Combobox,
5+
CreatableCombobox,
6+
ComboboxOption,
7+
Flex,
8+
Button,
9+
SingleSelect,
10+
SingleSelectOption,
11+
} from '@strapi/design-system';
412

513
<Meta title="Design System/Components/Combobox" component={Combobox} />
614

@@ -21,13 +29,51 @@ import { Combobox, ComboboxOption, CreatableCombobox } from '@strapi/design-syst
2129

2230
### Basic Usage
2331

24-
By default, the combobox uses both inline and list autocomplete, that is where as the user types suggestions
32+
By default, the combobox is uncontrolled & uses both inline and list autocomplete, that is where as the user types suggestions
2533
(based on the order of the options) are shown in the input field whilst the list gradually gets filtered.
2634

2735
<Canvas>
2836
<Story name="basic">
2937
{() => {
30-
const [value, setValue] = useState('');
38+
const [error, toggleError] = useState();
39+
const [disabled, toggleDisabled] = useState();
40+
return (
41+
<Flex direction="column" alignItems="stretch" gap={11}>
42+
<Combobox placeholder="My favourite fruit is..." label="Fruits" error={error} disabled={disabled}>
43+
<ComboboxOption value="apple">Apple</ComboboxOption>
44+
<ComboboxOption value="avocado">Avocado</ComboboxOption>
45+
<ComboboxOption value="banana">Banana</ComboboxOption>
46+
<ComboboxOption value="kiwi">Kiwi</ComboboxOption>
47+
<ComboboxOption value="mango">Mango</ComboboxOption>
48+
<ComboboxOption value="orange">Orange</ComboboxOption>
49+
<ComboboxOption value="strawberry">Strawberry</ComboboxOption>
50+
</Combobox>
51+
<Flex gap={2} justifyContent="center">
52+
<Button
53+
variant="danger-light"
54+
onClick={() => toggleError((s) => (s ? undefined : 'Oh no, the fruits have gone mouldy!'))}
55+
>
56+
{`${error ? 'Hide' : 'Show'} the error state`}
57+
</Button>
58+
<Button variant="tertiary" onClick={() => toggleDisabled((s) => !s)}>
59+
{`${disabled ? 'Hide' : 'Show'} the disabled state`}
60+
</Button>
61+
</Flex>
62+
</Flex>
63+
);
64+
}}
65+
</Story>
66+
</Canvas>
67+
68+
### Controlled
69+
70+
The combobox can be a controlled component by passing a `value` prop and an `onChange` callback, this also
71+
enables you to have the ability to "clear" the input.
72+
73+
<Canvas>
74+
<Story name="controlled">
75+
{() => {
76+
const [value, setValue] = useState();
3177
return (
3278
<Combobox
3379
placeholder="My favourite fruit is..."
@@ -154,6 +200,46 @@ still pass an `onCreateOption` callback to handle the creation of the new option
154200
</Story>
155201
</Canvas>
156202

203+
### Autocomplete settings
204+
205+
By default, the combobox uses both inline and list autocomplete, however you can change this behaviour
206+
to only be `list` or `none`. If you set the autocomplete mode to `none`, the first matching option will
207+
be visually focussed
208+
209+
<Canvas>
210+
<Story name="autocomplete">
211+
{() => {
212+
const [value, setValue] = useState('');
213+
const [autocompleteMode, setAutocompleteMode] = useState('both');
214+
return (
215+
<Flex direction="column" alignItems="stretch" gap={11}>
216+
<Combobox
217+
placeholder="My favourite fruit is..."
218+
label="Fruits"
219+
value={value}
220+
onChange={setValue}
221+
autocomplete={autocompleteMode}
222+
onClear={() => setValue('')}
223+
>
224+
<ComboboxOption value="apple">Apple</ComboboxOption>
225+
<ComboboxOption value="avocado">Avocado</ComboboxOption>
226+
<ComboboxOption value="banana">Banana</ComboboxOption>
227+
<ComboboxOption value="kiwi">Kiwi</ComboboxOption>
228+
<ComboboxOption value="mango">Mango</ComboboxOption>
229+
<ComboboxOption value="orange">Orange</ComboboxOption>
230+
<ComboboxOption value="strawberry">Strawberry</ComboboxOption>
231+
</Combobox>
232+
<SingleSelect label="Autocomplete Mode" value={autocompleteMode} onValueChange={setAutocompleteMode}>
233+
<SingleSelectOption value="both">both</SingleSelectOption>
234+
<SingleSelectOption value="list">list</SingleSelectOption>
235+
<SingleSelectOption value="none">none</SingleSelectOption>
236+
</SingleSelect>
237+
</Flex>
238+
);
239+
}}
240+
</Story>
241+
</Canvas>
242+
157243
## Props
158244

159245
### Combobox

0 commit comments

Comments
 (0)