From acf5c6683b828e6dec0094eba6a73c14d7566ada Mon Sep 17 00:00:00 2001 From: Stoyan <88034608+hinzzx@users.noreply.github.com> Date: Thu, 14 Sep 2023 22:53:37 +0300 Subject: [PATCH] docs: enhance storybook samples (#7454) *Bar Cleared the JSDoc enums; Changed the story name to -> Basic *Button Cleared JSDoc enums; Remove redunant Storybook samples; *DatePicker Cleared JSDoc enums; *DynamicSideContent Added custom styling to the native HTML tags as changing the themes wasn't updating the content. For example on Dark themes like Evening Horizon, both the background and the text would appear dark, which led to poor user experience; *FileUploader Cleared JSDoc enums Moved the Custom FileUploader sample to lower position, because we do not encourage using non-focusable elements; *Menu Fixed wrong property name headerText -> header-text because it wasnt showing on Mobile Devices; Changed sample name -> Basic with Header Text -> Basic *SplitButton Cleared JSDoc enums; Remove redunant Storybook samples; *StepInput Cleared JSDoc enums; Wrapped the main story component in the Storybook in a div with max-width: 13rem, due to component being stretched to the whole page, causing poor user experience; Simplified and removed redunant Storybook samples; *Switch Remove redunant Storybook samples; Reduced the Textual Switch samples because we do not encourage using Text in our switch component; *ToggleButton Enhance samples; --- packages/fiori/src/Bar.ts | 16 +--- packages/main/src/Button.ts | 21 ------ packages/main/src/DatePicker.ts | 9 --- packages/main/src/FileUploader.ts | 10 --- packages/main/src/SplitButton.ts | 12 --- packages/main/src/StepInput.ts | 9 --- .../_stories/fiori/Bar/Bar.stories.ts | 2 +- .../DynamicSideContent.stories.ts | 38 +++++----- .../_stories/main/Button/Button.stories.ts | 52 +++++-------- .../main/Calendar/Calendar.stories.ts | 2 +- .../main/DatePicker/DatePicker.stories.ts | 2 +- .../DateRangePicker.stories.ts | 4 +- .../DateTimePicker/DateTimePicker.stories.ts | 2 +- .../main/FileUploader/FileUploader.stories.ts | 9 +-- .../_stories/main/Menu/Menu.stories.ts | 4 +- .../main/SplitButton/SplitButton.stories.ts | 45 ++++------- .../main/StepInput/StepInput.stories.ts | 74 ++++++++----------- .../_stories/main/Switch/Switch.stories.ts | 30 +------- .../main/ToggleButton/ToggleButton.stories.ts | 42 ++++------- 19 files changed, 115 insertions(+), 268 deletions(-) diff --git a/packages/fiori/src/Bar.ts b/packages/fiori/src/Bar.ts index 2bad152b0816..70b4d323b01e 100644 --- a/packages/fiori/src/Bar.ts +++ b/packages/fiori/src/Bar.ts @@ -71,16 +71,6 @@ class Bar extends UI5Element { /** * Defines the component's design. * - *

- * Note: - * Available options are: - * - * * @type {sap.ui.webc.fiori.types.BarDesign} * @name sap.ui.webc.fiori.Bar.prototype.design * @defaultvalue "Header" @@ -90,7 +80,7 @@ class Bar extends UI5Element { design!: `${BarDesign}` /** - * Defines the content at the start of the bar + * Defines the content at the start of the bar. * @type {HTMLElement[]} * @name sap.ui.webc.fiori.Bar.prototype.startContent * @slot @@ -100,7 +90,7 @@ class Bar extends UI5Element { startContent!: Array; /** - * Defines the content in the middle of the bar + * Defines the content in the middle of the bar. * @type {HTMLElement[]} * @name sap.ui.webc.fiori.Bar.prototype.default * @slot middleContent @@ -110,7 +100,7 @@ class Bar extends UI5Element { middleContent!: Array /** - * Defines the content at the end of the bar + * Defines the content at the end of the bar. * @type {HTMLElement[]} * @name sap.ui.webc.fiori.Bar.prototype.endContent * @slot diff --git a/packages/main/src/Button.ts b/packages/main/src/Button.ts index 4885e558a350..0af5c780cf14 100644 --- a/packages/main/src/Button.ts +++ b/packages/main/src/Button.ts @@ -105,18 +105,6 @@ class Button extends UI5Element implements IFormElement { /** * Defines the component design. * - *

- * The available values are: - * - * - * * @type {sap.ui.webc.main.types.ButtonDesign} * @name sap.ui.webc.main.Button.prototype.design * @defaultvalue "Default" @@ -254,15 +242,6 @@ class Button extends UI5Element implements IFormElement { * Defines whether the button has special form-related functionality. * *

- * The available values are: - * - * - * - *

* Note: For the type property to have effect, you must add the following import to your project: * import "@ui5/webcomponents/dist/features/InputElementsFormSupport.js"; * diff --git a/packages/main/src/DatePicker.ts b/packages/main/src/DatePicker.ts index ecbc692885e6..49ef0fbd65fc 100644 --- a/packages/main/src/DatePicker.ts +++ b/packages/main/src/DatePicker.ts @@ -226,15 +226,6 @@ class DatePicker extends DateComponentBase implements IFormElement { /** * Defines the value state of the component. - *

- * Available options are: - * * * @type {sap.ui.webc.base.types.ValueState} * @name sap.ui.webc.main.DatePicker.prototype.valueState diff --git a/packages/main/src/FileUploader.ts b/packages/main/src/FileUploader.ts index e730e95548ca..f9eb5050801b 100644 --- a/packages/main/src/FileUploader.ts +++ b/packages/main/src/FileUploader.ts @@ -183,16 +183,6 @@ class FileUploader extends UI5Element implements IFormElement { /** * Defines the value state of the component. - *

- * Available options are: - * - * * @type {sap.ui.webc.base.types.ValueState} * @name sap.ui.webc.main.FileUploader.prototype.valueState * @defaultvalue "None" diff --git a/packages/main/src/SplitButton.ts b/packages/main/src/SplitButton.ts index ce24c642575e..4d2e89622258 100644 --- a/packages/main/src/SplitButton.ts +++ b/packages/main/src/SplitButton.ts @@ -135,18 +135,6 @@ class SplitButton extends UI5Element { /** * Defines the component design. * - *

- * The available values are: - * - * - * * @type {sap.ui.webc.main.types.ButtonDesign} * @name sap.ui.webc.main.SplitButton.prototype.design * @defaultvalue "Default" diff --git a/packages/main/src/StepInput.ts b/packages/main/src/StepInput.ts index 258645f5fa08..1e378eceba49 100644 --- a/packages/main/src/StepInput.ts +++ b/packages/main/src/StepInput.ts @@ -155,15 +155,6 @@ class StepInput extends UI5Element implements IFormElement { /** * Defines the value state of the component. - *

- * Available options are: - * * * @name sap.ui.webc.main.StepInput.prototype.valueState * @type {sap.ui.webc.base.types.ValueState} diff --git a/packages/playground/_stories/fiori/Bar/Bar.stories.ts b/packages/playground/_stories/fiori/Bar/Bar.stories.ts index b27b14c5f164..14abd8382a0f 100644 --- a/packages/playground/_stories/fiori/Bar/Bar.stories.ts +++ b/packages/playground/_stories/fiori/Bar/Bar.stories.ts @@ -34,7 +34,7 @@ const Template: UI5StoryArgs = (args) => html``; export const Basic = Template.bind({}); -Basic.storyName = "With Content and Design"; +Basic.storyName = "Basic"; Basic.args = { design: BarDesign.Header, startContent: ``, diff --git a/packages/playground/_stories/fiori/DynamicSideContent/DynamicSideContent.stories.ts b/packages/playground/_stories/fiori/DynamicSideContent/DynamicSideContent.stories.ts index 2a34c00dcf78..69806c662672 100644 --- a/packages/playground/_stories/fiori/DynamicSideContent/DynamicSideContent.stories.ts +++ b/packages/playground/_stories/fiori/DynamicSideContent/DynamicSideContent.stories.ts @@ -27,7 +27,20 @@ export default { argTypes, } as Meta; -const Template: UI5StoryArgs = (args) => html` = (args) => html` + + = (args) => htm export const Basic = Template.bind({}); Basic.args = { default: `
-

Main Content

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ex mi, elementum et ante commodo, semper sollicitudin magna. Sed dapibus ut tortor quis varius. Sed luctus sem at nunc porta vulputate. Suspendisse lobortis arcu est, quis ultrices ipsum fermentum a. Vestibulum a ipsum placerat ligula gravida fringilla at id ex. Etiam pellentesque lorem sed sagittis aliquam. Quisque semper orci risus, vel efficitur dui euismod aliquet. Morbi sapien sapien, rhoncus et rutrum nec, rhoncus id nisl. Cras non tincidunt enim, id eleifend neque.

+ Main Content +

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ex mi, elementum et ante commodo, semper sollicitudin magna. Sed dapibus ut tortor quis varius. Sed luctus sem at nunc porta vulputate. Suspendisse lobortis arcu est, quis ultrices ipsum fermentum a. Vestibulum a ipsum placerat ligula gravida fringilla at id ex. Etiam pellentesque lorem sed sagittis aliquam. Quisque semper orci risus, vel efficitur dui euismod aliquet. Morbi sapien sapien, rhoncus et rutrum nec, rhoncus id nisl. Cras non tincidunt enim, id eleifend neque.

`, sideContent: `
-

Side Content

-

Morbi lorem libero, imperdiet id condimentum ac, tempor ut velit. Integer a laoreet sem. Nunc at sagittis nisi. Sed placerat diam eu porttitor dignissim. Maecenas nec fringilla tortor. Pellentesque ut elit est. Curabitur quis elit at mauris ullamcorper fringilla. Nullam diam mi, porttitor dictum orci nec, molestie luctus metus. Nunc ut ex blandit, elementum erat eget, pulvinar sapien. Donec nec lorem eu nunc eleifend tempor at non tortor. In quam velit, ornare at rutrum ac, porta ac augue. Suspendisse venenatis semper lacus at venenatis. Praesent vestibulum ligula nulla, at tempus lorem consequat suscipit. Aenean consequat dapibus dui, at bibendum mauris porta a.

+ Side Content +

Morbi lorem libero, imperdiet id condimentum ac, tempor ut velit. Integer a laoreet sem. Nunc at sagittis nisi. Sed placerat diam eu porttitor dignissim. Maecenas nec fringilla tortor. Pellentesque ut elit est. Curabitur quis elit at mauris ullamcorper fringilla. Nullam diam mi, porttitor dictum orci nec, molestie luctus metus. Nunc ut ex blandit, elementum erat eget, pulvinar sapien. Donec nec lorem eu nunc eleifend tempor at non tortor. In quam velit, ornare at rutrum ac, porta ac augue. Suspendisse venenatis semper lacus at venenatis. Praesent vestibulum ligula nulla, at tempus lorem consequat suscipit. Aenean consequat dapibus dui, at bibendum mauris porta a.

`, + sideContentVisibility: SideContentVisibility.AlwaysShow, }; - -export const Position = Template.bind({}); -Position.storyName = "Side Content Position"; -Position.args = { - sideContentPosition: SideContentPosition.Start, - default: `
-

Main Content

-

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc ex mi, elementum et ante commodo, semper sollicitudin magna. Sed dapibus ut tortor quis varius. Sed luctus sem at nunc porta vulputate. Suspendisse lobortis arcu est, quis ultrices ipsum fermentum a. Vestibulum a ipsum placerat ligula gravida fringilla at id ex. Etiam pellentesque lorem sed sagittis aliquam. Quisque semper orci risus, vel efficitur dui euismod aliquet. Morbi sapien sapien, rhoncus et rutrum nec, rhoncus id nisl. Cras non tincidunt enim, id eleifend neque.

-
`, - sideContent: `
-

Side Content

-

Morbi lorem libero, imperdiet id condimentum ac, tempor ut velit. Integer a laoreet sem. Nunc at sagittis nisi. Sed placerat diam eu porttitor dignissim. Maecenas nec fringilla tortor. Pellentesque ut elit est. Curabitur quis elit at mauris ullamcorper fringilla. Nullam diam mi, porttitor dictum orci nec, molestie luctus metus. Nunc ut ex blandit, elementum erat eget, pulvinar sapien. Donec nec lorem eu nunc eleifend tempor at non tortor. In quam velit, ornare at rutrum ac, porta ac augue. Suspendisse venenatis semper lacus at venenatis. Praesent vestibulum ligula nulla, at tempus lorem consequat suscipit. Aenean consequat dapibus dui, at bibendum mauris porta a.

-
`, -}; \ No newline at end of file diff --git a/packages/playground/_stories/main/Button/Button.stories.ts b/packages/playground/_stories/main/Button/Button.stories.ts index e12b0d54e051..f6f33296eeb9 100644 --- a/packages/playground/_stories/main/Button/Button.stories.ts +++ b/packages/playground/_stories/main/Button/Button.stories.ts @@ -40,39 +40,23 @@ const Template: UI5StoryArgs = (args) => html` html` - ${story()}`, -]; \ No newline at end of file +export const DifferentDesigns: StoryFn = () => html` + Emphasized + Attention + Positive + Negative + Transparent +`; + +export const IconOnlyButtons: StoryFn = () => html` + + + + + +`; +IconOnlyButtons.storyName = "Icon-Only Buttons"; \ No newline at end of file diff --git a/packages/playground/_stories/main/Calendar/Calendar.stories.ts b/packages/playground/_stories/main/Calendar/Calendar.stories.ts index 7c64d2c3c8f5..f96a64699764 100644 --- a/packages/playground/_stories/main/Calendar/Calendar.stories.ts +++ b/packages/playground/_stories/main/Calendar/Calendar.stories.ts @@ -43,7 +43,7 @@ const Template: UI5StoryArgs = (args) => html` = (args) => html`< export const Basic = Template.bind({}); export const MinMax = Template.bind({}); -MinMax.storyName = "Min/Max Dates and Format Pattern"; +MinMax.storyName = "Formatted Date Range"; MinMax.args = { minDate: "1/1/2020", maxDate: "4/5/2020", @@ -54,7 +54,7 @@ MinMax.args = { }; export const LongFormat = Template.bind({}); -LongFormat.storyName = "Value, Format Pattern, and Delimiter"; +LongFormat.storyName = "Formatted Value and Delimiter"; LongFormat.args = { value: "March 31, 2023 ~ April 9, 2023", delimiter: "~", diff --git a/packages/playground/_stories/main/DateTimePicker/DateTimePicker.stories.ts b/packages/playground/_stories/main/DateTimePicker/DateTimePicker.stories.ts index b0ddd87c178f..53160d98cf48 100644 --- a/packages/playground/_stories/main/DateTimePicker/DateTimePicker.stories.ts +++ b/packages/playground/_stories/main/DateTimePicker/DateTimePicker.stories.ts @@ -50,7 +50,7 @@ FormatPattern.args = { }; export const MinMax = Template.bind({}); -MinMax.storyName = "Min/Max Dates and Format Pattern"; +MinMax.storyName = "Formatted Date Range"; MinMax.args = { value: "Jan 11, 2020, 11:11:11 AM", minDate: "Jan 11, 2020, 00:00:00 AM", diff --git a/packages/playground/_stories/main/FileUploader/FileUploader.stories.ts b/packages/playground/_stories/main/FileUploader/FileUploader.stories.ts index bfeaeb6b6b62..ac894d0880e8 100644 --- a/packages/playground/_stories/main/FileUploader/FileUploader.stories.ts +++ b/packages/playground/_stories/main/FileUploader/FileUploader.stories.ts @@ -48,13 +48,6 @@ Basic.decorators = [ ${story()}`, ]; -export const Custom = Template.bind({}); -Custom.storyName = "With Custom Design "; -Custom.args = { - hideInput: true, - default: `Upload File`, -}; - export const Advanced = Template.bind({}); Advanced.storyName = "Image Uploader"; Advanced.args = { @@ -69,7 +62,7 @@ Advanced.decorators = [
`;} ]; -export const Disabled = Template.bind({}); -Disabled.storyName = "Disabled SplitButton"; -Disabled.args = { - default: "Disabled", - disabled: true, -}; - -export const Design = Template.bind({}); -Design.args = { - default: "Attention", - design: ButtonDesign.Attention, -}; - -export const WithIcon = Template.bind({}); -WithIcon.args = { - default: "Icon", - icon: "add", -}; - -export const WithActiveIcon = Template.bind({}); -WithActiveIcon.args = { - default: "Press Me", - icon: "add", - activeIcon: "accept", -}; \ No newline at end of file +export const DifferentDesigns: StoryFn = () => html` + Emphasized + Attention + Positive + Negative + Transparent +`; \ No newline at end of file diff --git a/packages/playground/_stories/main/StepInput/StepInput.stories.ts b/packages/playground/_stories/main/StepInput/StepInput.stories.ts index c59189e03a37..72260c008946 100644 --- a/packages/playground/_stories/main/StepInput/StepInput.stories.ts +++ b/packages/playground/_stories/main/StepInput/StepInput.stories.ts @@ -10,7 +10,6 @@ import type { UI5StoryArgs } from "../../../types.js"; import { DocsPage } from "../../../.storybook/docs"; import type StepInput from "@ui5/webcomponents/dist/StepInput.js"; -import ValueState from "@ui5/webcomponents-base/dist/types/ValueState"; const component = "ui5-step-input"; @@ -25,56 +24,47 @@ export default { argTypes, } as Meta; -const Template: UI5StoryArgs = (args) => html` - ${unsafeHTML(args.valueStateMessage)} -`; +const Template: UI5StoryArgs = (args) => html` +
+ + ${unsafeHTML(args.valueStateMessage)} + +
`; export const Basic = Template.bind({}); Basic.args = { value: 5, }; -export const Readonly = Template.bind({}); -Readonly.args = { - value: 5, - readonly: true, -}; - -export const Disabled = Template.bind({}); -Disabled.args = { - value: 5, - disabled: true, -}; - -export const Design = Template.bind({}); -Design.storyName = "Value State"; -Design.args = { - value: 5, - valueState: ValueState.Success, -}; +export const DifferentValueStates: StoryFn = () => html` +

+

+

+

+`; export const MinMax = Template.bind({}); MinMax.storyName = "Min/Max and Step Values"; MinMax.args = { value: 0, - min: -100, - max: 100, + min: -50, + max: 50, step: 10, }; @@ -88,7 +78,7 @@ ValuePrecision.args = { }; export const Label = Template.bind({}); -Label.storyName = "With Label and Alignment"; +Label.storyName = "With Text Alignment"; Label.args = { id: "myStepInput", style: "text-align: left", @@ -96,6 +86,6 @@ Label.args = { required: true, }; Label.decorators = [ - (story) => html`Number + (story) => html`Number is left-aligned ${story()}`, ] \ No newline at end of file diff --git a/packages/playground/_stories/main/Switch/Switch.stories.ts b/packages/playground/_stories/main/Switch/Switch.stories.ts index f1c73a8b0890..f5bd859e8371 100644 --- a/packages/playground/_stories/main/Switch/Switch.stories.ts +++ b/packages/playground/_stories/main/Switch/Switch.stories.ts @@ -38,30 +38,8 @@ const Template: UI5StoryArgs = (args) => html``; export const Basic = Template.bind({}); - -export const WithText = Template.bind({}); -WithText.args = { - textOn: "On", - textOff: "Off", -}; - -export const Checked = Template.bind({}); -Checked.args = { - textOn: "Yes", - textOff: "No", - checked: true, -}; - -export const Disabled = Template.bind({}); -Disabled.args = { - disabled: true, - checked: true, -}; - -export const Design = Template.bind({}); -Design.args = { - design: SwitchDesign.Graphical, - accessibleName: "graphical", +Basic.args = { + accessibleName: "Switch with Accessible Name", }; export const RequiredInForm = Template.bind({}); @@ -85,13 +63,13 @@ RequiredInForm.decorators = [ }
-

Switch in Registration form sample

+

Switch in Registration form sample

- Please accept the terms and conditions, in order to proceed + Please accept the terms and conditions, in order to proceed
${story()}
diff --git a/packages/playground/_stories/main/ToggleButton/ToggleButton.stories.ts b/packages/playground/_stories/main/ToggleButton/ToggleButton.stories.ts index 6563c48c7b92..c48d4c6ae7ba 100644 --- a/packages/playground/_stories/main/ToggleButton/ToggleButton.stories.ts +++ b/packages/playground/_stories/main/ToggleButton/ToggleButton.stories.ts @@ -39,29 +39,19 @@ Basic.args = { default: "Default", }; -export const Pressed = Template.bind({}); -Pressed.args = { - default: "Pressed", - pressed: true, -}; - -export const DisabledAndPressed = Template.bind({}); -DisabledAndPressed.args = { - default: "ToggleButton", - pressed: true, - disabled: true, -}; - -export const IconOnly = Template.bind({}); -IconOnly.storyName = "Icon-Only ToggleButton"; -IconOnly.args = { - icon: "add", -}; - -export const WithIconAndDesign = Template.bind({}); -WithIconAndDesign.args = { - default: "ToggleButton", - design: ButtonDesign.Positive, - pressed: false, - icon: "add", -}; \ No newline at end of file +export const DifferentDesigns: StoryFn = () => html` + Emphasized + Attention + Positive + Negative + Transparent +`; + +export const IconOnlyToggleButtons: StoryFn = () => html` + + + + + +`; +IconOnlyToggleButtons.storyName = "Icon-Only Toggle Buttons"; \ No newline at end of file