Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap all website examples in ThemeProvider #1353

Merged
merged 2 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions apps/website/src/components/LiveExample.astro
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,7 @@ if (code.includes('Copyright (c) Bentley Systems')) {
---

<div class='demo-box'>
<ThemeProvider
className='demo-iui-wrapper'
theme='dark'
themeOptions={{ applyBackground: false }}
client:load
>
<slot />
</ThemeProvider>
<slot />
<OpenInCodesandbox class='sandbox-link' code={code} />
</div>
<demo-code>
Expand Down Expand Up @@ -94,7 +87,7 @@ if (code.includes('Copyright (c) Bentley Systems')) {
border-radius: var(--border-radius-1);
}

.demo-iui-wrapper {
.demo-box :global([data-iui-theme]) {
height: 100%;
width: 100%;
overflow: auto;
Expand Down
14 changes: 2 additions & 12 deletions examples/InputGroup.checkboxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import * as React from 'react';
import { InputGroup, Checkbox } from '@itwin/itwinui-react';

export default (args) => {
export default () => {
const option1Label = 'Football';
const option2Label = 'Hockey';
const [option1, setOption1] = React.useState(true);
Expand Down Expand Up @@ -33,32 +33,22 @@ export default (args) => {
setOption2(value);
};
return (
<InputGroup
label='Select your hobbies'
message='Choose some hobbies'
{...args}
>
<InputGroup label='Select your hobbies' message='Choose some hobbies'>
<Checkbox
onChange={(event) => onAllChange(event.target.checked)}
label='Select all'
indeterminate={isIndeterminate}
checked={allOptions}
disabled={args.disabled}
required={args.required}
/>
<Checkbox
onChange={(event) => setOption1(event.target.checked)}
label={option1Label}
checked={option1}
disabled={args.disabled}
required={args.required}
/>
<Checkbox
onChange={(event) => setOption2(event.target.checked)}
label={option2Label}
checked={option2}
disabled={args.disabled}
required={args.required}
/>
</InputGroup>
);
Expand Down
41 changes: 16 additions & 25 deletions examples/Select.disable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,25 @@
import * as React from 'react';
import { Select } from '@itwin/itwinui-react';

export default (args) => {
const {
options = [
{
value: 1,
label: 'Item #1',
},
{
value: 2,
label: 'Item #2',
},
{
value: 3,
label: 'Item #3',
},
],
placeholder = 'Placeholder text',
...rest
} = args;
const [value, setValue] = React.useState<number | undefined>(undefined);
export default () => {
return (
<Select<number>
disabled
{...rest}
options={options}
value={value}
onChange={setValue}
placeholder={placeholder}
options={[
{
value: 1,
label: 'Item #1',
},
{
value: 2,
label: 'Item #2',
},
{
value: 3,
label: 'Item #3',
},
]}
placeholder={'Placeholder text'}
/>
);
};
49 changes: 20 additions & 29 deletions examples/Select.icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,27 @@ import {
SvgSmileyNeutral,
} from '@itwin/itwinui-icons-react';

export default (args) => {
const {
options = [
{
value: 'happy',
label: 'Happy',
icon: <SvgSmileyHappy />,
},
{
value: 'neutral',
label: 'Neutral',
icon: <SvgSmileyNeutral />,
},
{
value: 'sad',
label: 'Sad',
icon: <SvgSmileySad />,
},
],
placeholder = 'How are you today?',
...rest
} = args;
const [value, setValue] = React.useState<string | undefined>(undefined);
export default () => {
return (
<Select<string>
{...rest}
options={options}
value={value}
onChange={setValue}
placeholder={placeholder}
<Select
options={[
{
value: 'happy',
label: 'Happy',
icon: <SvgSmileyHappy />,
},
{
value: 'neutral',
label: 'Neutral',
icon: <SvgSmileyNeutral />,
},
{
value: 'sad',
label: 'Sad',
icon: <SvgSmileySad />,
},
]}
placeholder={'How are you today?'}
/>
);
};
43 changes: 17 additions & 26 deletions examples/Select.statuses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,26 @@
import * as React from 'react';
import { MenuItem, Select } from '@itwin/itwinui-react';

export default (args) => {
const {
options = [
{
value: 'yellow',
label: 'Yellow',
},
{
value: 'green',
label: 'Green',
},
{
value: 'red',
label: 'Red',
},
],
placeholder = 'Placeholder text',
...rest
} = args;
const [selectedValue, setSelectedValue] = React.useState<string | undefined>(
undefined,
);
export default () => {
const options = [
{
value: 'yellow',
label: 'Yellow',
},
{
value: 'green',
label: 'Green',
},
{
value: 'red',
label: 'Red',
},
];

return (
<Select<string>
{...rest}
options={options}
value={selectedValue}
onChange={setSelectedValue}
placeholder={placeholder}
placeholder={'Placeholder text'}
itemRenderer={(option) => (
<MenuItem
style={{
Expand Down
53 changes: 20 additions & 33 deletions examples/Select.sublabels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,27 @@
*--------------------------------------------------------------------------------------------*/
import * as React from 'react';
import { Select } from '@itwin/itwinui-react';
import { useState } from 'react';

export default (args) => {
const {
options = [
{
value: 1,
label: 'Item #1',
sublabel: 'Sublabel #1',
},
{
value: 2,
label: 'Item #2',
sublabel: 'Sublabel #2',
},
{
value: 3,
label: 'Item #3',
sublabel: 'Sublabel #3',
},
],
placeholder = 'Placeholder text',
size = 'large',
...rest
} = args;
const [value, setValue] = useState<number | undefined>(undefined);
export default () => {
const options = [
{
value: 1,
label: 'Item #1',
sublabel: 'Sublabel #1',
},
{
value: 2,
label: 'Item #2',
sublabel: 'Sublabel #2',
},
{
value: 3,
label: 'Item #3',
sublabel: 'Sublabel #3',
},
];

return (
<Select<number>
{...rest}
options={options}
value={value}
onChange={setValue}
placeholder={placeholder}
size={size}
/>
<Select options={options} placeholder={'Placeholder text'} size={'large'} />
);
};
43 changes: 19 additions & 24 deletions examples/Select.truncate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@ import * as React from 'react';
import { MenuItem, MiddleTextTruncation, Select } from '@itwin/itwinui-react';
import { useCallback, useState } from 'react';

export default (args) => {
const {
options = [
{
value:
'MyFileWithAReallyLongNameThatWillBeTruncatedBecauseItIsReallyThatLongSoHardToBelieve_FinalVersion_V2.html',
label:
'MyFileWithAReallyLongNameThatWillBeTruncatedBecauseItIsReallyThatLongSoHardToBelieve_FinalVersion_V2.html',
},
{
value: 'ShortNameFile.jpg',
label: 'ShortNameFile.jpg',
},
{
value: 'SomeOtherFile.dgn',
label: 'SomeOtherFile.dgn',
},
],
placeholder = 'Placeholder text',
...rest
} = args;
export default () => {
const options = [
{
value:
'MyFileWithAReallyLongNameThatWillBeTruncatedBecauseItIsReallyThatLongSoHardToBelieve_FinalVersion_V2.html',
label:
'MyFileWithAReallyLongNameThatWillBeTruncatedBecauseItIsReallyThatLongSoHardToBelieve_FinalVersion_V2.html',
},
{
value: 'ShortNameFile.jpg',
label: 'ShortNameFile.jpg',
},
{
value: 'SomeOtherFile.dgn',
label: 'SomeOtherFile.dgn',
},
];
const [selectedValue, setSelectedValue] = useState<string | undefined>(
options[0].value,
);
Expand All @@ -39,12 +35,11 @@ export default (args) => {
[],
);
return (
<Select<string>
{...rest}
<Select
options={options}
value={selectedValue}
onChange={setSelectedValue}
placeholder={placeholder}
placeholder={'Placeholder text'}
itemRenderer={(option) => (
<MenuItem>
<MiddleTextTruncation
Expand Down
Loading