Skip to content

docs(ObjectStatus): add JSDoc comments, enhance story #935

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

Merged
merged 2 commits into from
Nov 11, 2020
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
98 changes: 98 additions & 0 deletions packages/main/src/components/ObjectStatus/ObjectStatus.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
import { ObjectStatus } from '@ui5/webcomponents-react/lib/ObjectStatus';
import { createSelectArgTypes } from '@shared/stories/createSelectArgTypes';
import { ValueState } from '@ui5/webcomponents-react/lib/ValueState';
import { Icon } from '@ui5/webcomponents-react/lib/Icon';
import { DocsHeader } from '@shared/stories/DocsHeader';
import { DocsCommonProps } from '@shared/stories/DocsCommonProps';

<Meta
title="Components / ObjectStatus"
component={ObjectStatus}
argTypes={{
...createSelectArgTypes({ state: ValueState }),
children: { control: 'text' },
...DocsCommonProps
}}
args={{
state: ValueState.None,
children: 'ObjectStatus',
showDefaultIcon: true,
style: {},
className: '',
tooltip: '',
slot: '',
ref: null
}}
/>

<DocsHeader />

<Canvas>
<Story name="Default">
{(args) => {
return <ObjectStatus {...args} />;
}}
</Story>
</Canvas>

<ArgsTable story="Default" />

<br />

# Stories

<br />

## ObjectStatus with default icons

<Canvas>
<Story name="None" args={{ state: ValueState.None, children: `Value State: ${ValueState.None}` }}>
{(args) => {
return <ObjectStatus {...args} />;
}}
</Story>
<Story
name="Information"
args={{ state: ValueState.Information, children: `Value State: ${ValueState.Information}` }}
>
{(args) => {
return <ObjectStatus {...args} />;
}}
</Story>
<Story name="Success" args={{ state: ValueState.Success, children: `Value State: ${ValueState.Success}` }}>
{(args) => {
return <ObjectStatus {...args} />;
}}
</Story>
<Story name="Warning" args={{ state: ValueState.Warning, children: `Value State: ${ValueState.Warning}` }}>
{(args) => {
return <ObjectStatus {...args} />;
}}
</Story>
<Story name="Error" args={{ state: ValueState.Error, children: `Value State: ${ValueState.Error}` }}>
{(args) => {
return <ObjectStatus {...args} />;
}}
</Story>
</Canvas>

## ObjectStatus with custom Icon

<Canvas>
<Story name="with custom Icon" args={{ icon: <Icon name="sys-cancel" /> }}>
{(args) => {
return <ObjectStatus {...args} />;
}}
</Story>
</Canvas>

## ObjectStatus with Icon only

<Canvas>
<Story name="with Icon only" args={{ icon: <Icon name="sys-cancel" />, children: null }}>
{(args) => {
return <ObjectStatus {...args} />;
}}
</Story>
</Canvas>
41 changes: 0 additions & 41 deletions packages/main/src/components/ObjectStatus/demo.stories.tsx

This file was deleted.

19 changes: 18 additions & 1 deletion packages/main/src/components/ObjectStatus/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,24 @@ import { CommonProps } from '../../interfaces/CommonProps';
import styles from './ObjectStatus.jss';

export interface ObjectStatusPropTypes extends CommonProps {
/**
* Defines the text of the `ObjectStatus`.<br />
* __Note:__ Although this slot accepts HTML Elements, it is strongly recommended that you only use text in order to preserve the intended design.
*/
children?: string | number | ReactNode;
/**
* Defines the icon in front of the `ObjectStatus` text.<br />
* __Note:__ Although this slot accepts HTML Elements, it is strongly recommended that you only use `Icon` in order to preserve the intended design.
*/
icon?: ReactNode;
/**
* Defines the value state of the <code>ObjectStatus</code>. <br><br> Available options are: <ul> <li><code>None</code></li> <li><code>Error</code></li> <li><code>Warning</code></li> <li><code>Success</code></li> <li><code>Information</code></li> </ul>
*/
state?: ValueState;
/**
* Defines whether the default icon for each `ValueState` should be displayed.<br />
* __Note:__ If the `icon` prop was set, `showDefaultIcon` has no effect.
*/
showDefaultIcon?: boolean;
}

Expand All @@ -39,7 +54,9 @@ const getDefaultIcon = (state) => {
};

const useStyles = createComponentStyles(styles, { name: 'ObjectStatus' });

/**
* Status information that can be either text with a value state, or an icon.
*/
const ObjectStatus: FC<ObjectStatusPropTypes> = forwardRef((props: ObjectStatusPropTypes, ref: Ref<HTMLDivElement>) => {
const { state, showDefaultIcon, children, icon, className, style, tooltip, slot } = props;
const iconToRender = useMemo(() => {
Expand Down