Skip to content

Commit e73dc78

Browse files
authored
Merge pull request #293 from brionmario/migrate-default-props
feat: add components & new icons
2 parents dcab32f + 6d70f06 commit e73dc78

File tree

48 files changed

+1388
-66
lines changed

Some content is hidden

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

48 files changed

+1388
-66
lines changed
+23
Loading
+23
Loading

packages/react/.storybook/story-config.ts

+21-9
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ enum StorybookCategories {
3232
Utils = 'Utils'
3333
}
3434

35+
// NOTE: Please keep the stories in alphabetical order.
3536
export type Stories =
3637
| 'Accordion'
3738
| 'AccordionDetails'
@@ -46,34 +47,36 @@ export type Stories =
4647
| 'Avatar'
4748
| 'Backdrop'
4849
| 'Badge'
49-
| 'Breadcrumbs'
5050
| 'Box'
51+
| 'Breadcrumbs'
5152
| 'Button'
52-
| 'CircularProgress'
5353
| 'Card'
5454
| 'CardActions'
5555
| 'CardContent'
5656
| 'CardHeader'
5757
| 'Carousel'
5858
| 'Checkbox'
59-
| 'CircularProgressAvatar'
6059
| 'Chip'
60+
| 'CircularProgress'
61+
| 'CircularProgressAvatar'
6162
| 'Code'
63+
| 'Colors'
64+
| 'Collapse'
6265
| 'CollapsibleNavbarItem'
6366
| 'ColorModeToggle'
64-
| 'Colors'
6567
| 'Container'
68+
| 'CountryFlag'
6669
| 'DataGrid'
70+
| 'Dialog'
6771
| 'Divider'
6872
| 'Drawer'
69-
| 'CountryFlag'
7073
| 'Fab'
7174
| 'Footer'
75+
| 'FormControl'
7276
| 'FormControlLabel'
7377
| 'FormGroup'
74-
| 'FormLabel'
7578
| 'FormHelperText'
76-
| 'FormControl'
79+
| 'FormLabel'
7780
| 'Grid'
7881
| 'Header'
7982
| 'IconButton'
@@ -92,19 +95,19 @@ export type Stories =
9295
| 'ListItemText'
9396
| 'Menu'
9497
| 'MenuItem'
95-
| 'UserDropdownMenu'
9698
| 'Navbar'
9799
| 'NavbarItem'
98100
| 'OutlinedInput'
99101
| 'Paper'
100-
| 'Popover'
101102
| 'PhoneNumberInput'
103+
| 'Popover'
102104
| 'Radio'
103105
| 'RadioGroup'
104106
| 'Select'
105107
| 'SignIn'
106108
| 'Skeleton'
107109
| 'Snackbar'
110+
| 'Stack'
108111
| 'Stepper'
109112
| 'Switch'
110113
| 'Tab'
@@ -215,6 +218,9 @@ const StoryConfig: StorybookConfig = {
215218
Code: {
216219
hierarchy: `${StorybookCategories.DataDisplay}/Code`,
217220
},
221+
Collapse: {
222+
hierarchy: `${StorybookCategories.Utils}/Collapse`,
223+
},
218224
CollapsibleNavbarItem: {
219225
hierarchy: `${StorybookCategories.Navigation}/Collapsible Navbar Item`,
220226
},
@@ -230,6 +236,9 @@ const StoryConfig: StorybookConfig = {
230236
DataGrid: {
231237
hierarchy: `${StorybookCategories.DataDisplay}/DataGrid`,
232238
},
239+
Dialog: {
240+
hierarchy: `${StorybookCategories.Feedback}/Dialog`,
241+
},
233242
Divider: {
234243
hierarchy: `${StorybookCategories.DataDisplay}/Divider`,
235244
},
@@ -358,6 +367,9 @@ const StoryConfig: StorybookConfig = {
358367
Snackbar: {
359368
hierarchy: `${StorybookCategories.Feedback}/Snackbar`,
360369
},
370+
Stack: {
371+
hierarchy: `${StorybookCategories.Layout}/Stack`,
372+
},
361373
Stepper: {
362374
hierarchy: `${StorybookCategories.Surfaces}/Stepper`,
363375
},

packages/react/src/components/AlertTitle/AlertTitle.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
*/
1818

1919
import MuiAlertTitle from '@mui/material/AlertTitle';
20-
import type {AlertTitleProps, AlertTitleProps as MuiAlertTitleProps} from '@mui/material/AlertTitle';
20+
import type {AlertTitleProps as MuiAlertTitleProps} from '@mui/material/AlertTitle';
2121
import type {OverridableComponent} from '@mui/material/OverridableComponent';
2222
import clsx from 'clsx';
2323
import {forwardRef} from 'react';
2424
import type {ReactElement, ElementType, Ref} from 'react';
2525
import type {TypographyTypeMap} from '../Typography';
2626
import './alert-title.scss';
2727

28-
export type AlertProps<C extends ElementType = ElementType> = {
28+
export type AlertTitleProps<C extends ElementType = ElementType> = {
2929
/**
3030
* The component used for the root node. Either a string to use a HTML element or a component.
3131
*/
@@ -57,7 +57,7 @@ export type AlertProps<C extends ElementType = ElementType> = {
5757
*/
5858
const AlertTitle: OverridableComponent<TypographyTypeMap<AlertTitleProps>> = forwardRef(
5959
<C extends ElementType = ElementType>(
60-
{className, ...rest}: AlertProps<C>,
60+
{className, ...rest}: AlertTitleProps<C>,
6161
ref: Ref<HTMLDivElement>,
6262
): ReactElement => {
6363
const classes: string = clsx('oxygen-alert-title', className);

packages/react/src/components/Autocomplete/__tests__/__snapshots__/Autocomplete.test.tsx.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ exports[`Alert should match the snapshot 1`] = `
1818
Movie
1919
</label>
2020
<div
21-
class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root css-wb57ya-MuiFormControl-root-MuiTextField-root"
21+
class="MuiFormControl-root MuiFormControl-fullWidth MuiTextField-root OxygenTextField-root css-wb57ya-MuiFormControl-root-MuiTextField-root"
2222
>
2323
<div
24-
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-115mmlx-MuiInputBase-root-MuiOutlinedInput-root"
24+
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-fullWidth MuiInputBase-formControl MuiInputBase-adornedEnd MuiAutocomplete-inputRoot css-118ft55-MuiInputBase-root-MuiOutlinedInput-root"
2525
>
2626
<input
2727
aria-autocomplete="list"
2828
aria-expanded="false"
2929
aria-invalid="false"
3030
autocapitalize="none"
3131
autocomplete="off"
32-
class="MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputAdornedEnd MuiAutocomplete-input MuiAutocomplete-inputFocused css-11fn00k-MuiInputBase-input-MuiOutlinedInput-input"
32+
class="MuiInputBase-input MuiOutlinedInput-input MuiInputBase-inputAdornedEnd MuiAutocomplete-input MuiAutocomplete-inputFocused css-1d0o5yu-MuiInputBase-input-MuiOutlinedInput-input"
3333
id=":r2:"
3434
role="combobox"
3535
spellcheck="false"

packages/react/src/components/Backdrop/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@
1919
export {default} from './Backdrop';
2020
export * from './Backdrop';
2121

22-
export {BackdropRoot} from '@mui/material/Backdrop';
2322
export type {BackdropComponentsPropsOverrides, BackdropTypeMap} from '@mui/material/Backdrop';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import {ArgsTable, Source, Story, Canvas, Meta} from '@storybook/addon-docs';
2+
import {useArgs} from '@storybook/client-api';
3+
import dedent from 'ts-dedent';
4+
import Collapse from './Collapse.tsx';
5+
import StoryConfig from '../../../.storybook/story-config.ts';
6+
import Box from '../Box/Box.tsx';
7+
import FormControlLabel from '../FormControlLabel/FormControlLabel.tsx';
8+
import FormGroup from '../FormGroup/FormGroup.tsx';
9+
import Paper from '../Paper/Paper.tsx';
10+
import Switch from '../Switch/Switch.tsx';
11+
12+
export const meta = {
13+
component: Collapse,
14+
title: StoryConfig.Collapse.hierarchy,
15+
};
16+
17+
<Meta title={meta.title} component={meta.component} />
18+
19+
export const Template = ({...args}) => {
20+
const [runtimeArgs, updateArgs] = useArgs();
21+
const {in: checked} = runtimeArgs;
22+
return (
23+
<Box sx={{p: 3}}>
24+
<FormGroup sx={{mb: 2}}>
25+
<FormControlLabel
26+
control={<Switch checked={checked} onChange={() => updateArgs({...runtimeArgs, in: !checked})} />}
27+
label="Show"
28+
/>
29+
</FormGroup>
30+
<Collapse in={checked} {...args}>
31+
<Paper sx={{background: 'red', height: '200px', width: '200px'}} />
32+
</Collapse>
33+
</Box>
34+
);
35+
};
36+
37+
# Collapse
38+
39+
- [Overview](#overview)
40+
- [Props](#props)
41+
- [Usage](#usage)
42+
43+
## Overview
44+
45+
Expand from the start edge of the child element. Use the `orientation` prop if you need a horizontal collapse. The
46+
`collapsedSize` prop can be used to set the minimum width/height when not expanded.
47+
48+
<Canvas>
49+
<Story
50+
name="Overview"
51+
args={{in: false}}
52+
parameters={{
53+
docs: {iframeHeight: 476, inlineStories: false},
54+
}}
55+
>
56+
{Template.bind({})}
57+
</Story>
58+
</Canvas>
59+
60+
## Props
61+
62+
<ArgsTable story="Overview" />
63+
64+
## Usage
65+
66+
Import and use the `Collapse` component in your components as follows.
67+
68+
<Source
69+
language="jsx"
70+
dark
71+
format
72+
code={dedent`
73+
import Collapse from '@oxygen-ui/react/Collapse';\n
74+
function Demo() {
75+
return (
76+
<Collapse />
77+
);
78+
}`}
79+
/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
import MuiCollapse from '@mui/material/Collapse';
20+
import type {CollapseProps as MuiCollapseProps} from '@mui/material/Collapse';
21+
import type {OverridableComponent, OverridableTypeMap} from '@mui/material/OverridableComponent';
22+
import type {TransitionProps} from '@mui/material/transitions';
23+
import clsx from 'clsx';
24+
import {forwardRef} from 'react';
25+
import type {ReactElement, Ref, ElementType} from 'react';
26+
27+
export type CollapseProps<C extends ElementType = ElementType<TransitionProps>> = {
28+
/**
29+
* The component used for the root node. Either a string to use a HTML element or a component.
30+
*/
31+
component?: C;
32+
} & Omit<MuiCollapseProps, 'component'>;
33+
34+
/**
35+
* A Transition component to expand from the start edge of the child element.
36+
*
37+
* Demos:
38+
*
39+
* - [Card (Oxygen UI)](https://wso2.github.io/oxygen-ui/react/?path=/docs/surfaces-card)
40+
* - [Card (MUI)](https://mui.com/material-ui/react-card/)
41+
* - [Lists (Oxygen UI)](https://wso2.github.io/oxygen-ui/react/?path=/docs/data-display-list)
42+
* - [Lists (MUI)](https://mui.com/material-ui/react-list/)
43+
* - [Collapse (Oxygen UI)](https://wso2.github.io/oxygen-ui/react/?path=/docs/utils-collapse)
44+
* - [Transitions (MUI)](https://mui.com/material-ui/transitions/)
45+
*
46+
* API:
47+
*
48+
* - [Collapse API](https://mui.com/material-ui/api/collapse/)
49+
* - inherits [Transition API](http://reactcommunity.org/react-transition-group/transition/#Transition-props)
50+
*
51+
* @remarks
52+
* - ✔️ Props of the [Transition](https://mui.com/material-ui/transitions/) component are also available.
53+
* - ✅ `component` prop is supported.
54+
* - ✅ The `ref` is forwarded to the root element.
55+
*
56+
* @template C - The type of the component.
57+
* @param props - The props for the Collapse component.
58+
* @param ref - The ref to be forwarded to the MuiCollapse component.
59+
* @returns The rendered Collapse component.
60+
*/
61+
const Collapse: OverridableComponent<OverridableTypeMap> = forwardRef(
62+
({className, ...rest}: CollapseProps<ElementType<TransitionProps>>, ref: Ref<HTMLDivElement>): ReactElement => (
63+
<MuiCollapse ref={ref} className={clsx('OxygenCollapse-root', className)} {...rest} />
64+
),
65+
) as OverridableComponent<OverridableTypeMap>;
66+
67+
export default Collapse;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com).
3+
*
4+
* WSO2 LLC. licenses this file to you under the Apache License,
5+
* Version 2.0 (the "License"); you may not use this file except
6+
* in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing,
12+
* software distributed under the License is distributed on an
13+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
* KIND, either express or implied. See the License for the
15+
* specific language governing permissions and limitations
16+
* under the License.
17+
*/
18+
19+
import {render} from '@unit-testing';
20+
import Collapse from '../Collapse';
21+
22+
describe('Collapse', () => {
23+
it('should render successfully', () => {
24+
const {baseElement} = render(<Collapse />);
25+
expect(baseElement).toBeTruthy();
26+
});
27+
28+
it('should match the snapshot', () => {
29+
const {baseElement} = render(<Collapse />);
30+
expect(baseElement).toMatchSnapshot();
31+
});
32+
});

0 commit comments

Comments
 (0)