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

[Storybook]: Configuring ArgTypes filtering #282

Merged
merged 20 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
105f490
DS-240: rename isExternalLink as external
videoeero Feb 14, 2024
2ed1c2c
DS-240: adjust link color API naming
videoeero Feb 14, 2024
1964dd2
DS-240: cleaning and checking
videoeero Feb 14, 2024
8fe5717
Merge branch 'main' into DS-240-link-and-notification-check
videoeero Feb 15, 2024
ee9886e
DS-240: replace broken mdx tables with native html tables
videoeero Feb 15, 2024
3953fcc
DS-240: create filter regex for storybook and add it as default
videoeero Feb 15, 2024
98a470d
DS-240: cleaning
videoeero Feb 15, 2024
829360d
DS-240: adjust storybook excludes
videoeero Feb 15, 2024
161eedd
DS-240: default argTypes configs
videoeero Feb 15, 2024
8e48ec2
DS-240: dialog example adjusts
videoeero Feb 15, 2024
945234e
Merge branch 'main' into DS-240-link-and-notification-check
videoeero Feb 15, 2024
e61a012
Merge branch 'main' into DS-240-link-and-notification-check
MayaMarjut Feb 16, 2024
3e2f7a1
DS-240: Comment out hidden components from sandbox environment, in or…
RiinaKuu Feb 16, 2024
45944d6
DS-240: Remove unnecessary excludeRegex imports
RiinaKuu Feb 16, 2024
263df9b
DS-240: Add size control to dialog story
RiinaKuu Feb 16, 2024
05b85a4
DS-240: Fix Button exclude properties
RiinaKuu Feb 16, 2024
317e36c
DS-240: Revert color name changes since it causes problems, address t…
RiinaKuu Feb 16, 2024
84c9e72
Merge branch 'DS-240-link-and-notification-check' of https://github.c…
RiinaKuu Feb 16, 2024
07a4562
DS-240: Add few basic tests for Link Component
RiinaKuu Feb 16, 2024
a41590d
Merge branch 'main' into DS-240-link-and-notification-check
MayaMarjut Feb 16, 2024
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
1 change: 1 addition & 0 deletions ngx-fudis/.storybook/compodoc.tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../tsconfig.json",
"include": [
"../projects/ngx-fudis/src/**/*.stories.ts",
"../projects/ngx-fudis/src/**/*.component.ts",
"../projects/ngx-fudis/src/**/*.directive.ts",
"../projects/ngx-fudis/src/**/*.service.ts"
Expand Down
13 changes: 12 additions & 1 deletion ngx-fudis/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@ import { moduleMetadata } from "@storybook/angular";
import { setCompodocJson } from "@storybook/addon-docs/angular";
import docJson from "../documentation.json";
import getVersion from "./getVersion";
import { excludeRegex } from "../projects/ngx-fudis/src/lib/utilities/storybook";

setCompodocJson(docJson);

const preview = {
parameters: {
actions: { argTypesRegex: "^on[A-Z].*" },

controls: {
exclude: excludeRegex(),
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
docs: { story: { inline: true } },
docs: {
argTypes: {
exclude: excludeRegex(),
},
controls: {
exclude: excludeRegex(),
},
story: { inline: true },
},
options: {
storySort: {
order: [
Expand Down
16 changes: 6 additions & 10 deletions ngx-fudis/projects/dev/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@

<fudis-expandable [title]="'Description list'">
<ng-template fudisContent type="expandable">
<fudis-description-list [data]="testData"></fudis-description-list>
<!-- <fudis-description-list [data]="testData"></fudis-description-list> -->
</ng-template>
</fudis-expandable>

Expand All @@ -96,20 +96,16 @@

<fudis-footer>
<ng-template fudisFooterRight>
<fudis-link
[href]="'example.com'"
[linkTitle]="'Tietosuojaseloste'"
[isExternalLink]="true"
/>
<fudis-link [href]="'example.com'" [linkTitle]="'Tietosuojaseloste'" [external]="true" />
<fudis-link
[href]="'example.com'"
[linkTitle]="'Saavutettavuusseloste'"
[isExternalLink]="true"
[external]="true"
/>
<fudis-link [href]="'example.com'" [linkTitle]="'Järjestelmätiedot'" />
</ng-template>
<ng-template fudisFooterLeft>
<fudis-link [href]="'example.com'" [linkTitle]="'Promo link'" [isExternalLink]="true" />
<fudis-link [href]="'example.com'" [linkTitle]="'Promo link'" [external]="true" />
</ng-template>
</fudis-footer>
</div>
Expand Down Expand Up @@ -150,11 +146,11 @@
'This text-input has multiple validators: required, minlength and maxlength'
"
/>
<fudis-radio-button-group
<!-- <fudis-radio-button-group
[title]="'Choose the truth'"
[control]="testFormGroup.controls['truth']"
[options]="radioButtonOptions"
/>
/> -->
</ng-template>
</fudis-fieldset>
</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@
[message]="'Backend threw an error, it is not totally fault of this component'"
/>
</fudis-text-input>
<fudis-radio-button-group
<!-- <fudis-radio-button-group
[title]="t('chooseTruth')"
[helpText]="t('chooseTruthHelp')"
[control]="testFormGroup.controls['truth']"
[options]="radioButtonOptions"
/>
<fudis-dropdown
/> -->
<!-- <fudis-dropdown
[id]="'dropdown-id-123'"
[label]="'Some dropdown'"
[options]="dropdownOptions"
Expand All @@ -68,7 +68,7 @@
[options]="dropdownOptions"
[multipleOption]="true"
[control]="testFormGroup.controls['dropdownMulti']"
/>
/> -->
<fudis-datepicker
[label]="'Select some date'"
[control]="testFormGroup.controls['date']"
Expand All @@ -95,24 +95,24 @@
<ng-template fudisContent type="expandable">
<fudis-grid [columns]="'inputLg'">
<fudis-heading [level]="3" [size]="'md'">Single-select dropdown</fudis-heading>
<fudis-autocomplete
<!-- <fudis-autocomplete
[label]="'Choose item'"
[variant]="'dropdown'"
[id]="'dropdown-1234'"
[options]="multipleOptions"
[control]="testFormGroup.controls['autocompleteDropdown']"
/>
/> -->
<fudis-heading [level]="3" [size]="'md'">Single-select search</fudis-heading>
<fudis-autocomplete
<!-- <fudis-autocomplete
[label]="'Search item'"
[options]="multipleOptions"
[control]="testFormGroup.controls['autocompleteSearch']"
/>
/> -->
<fudis-heading [level]="3" [size]="'md'">Autocomplete multi-select dropdown</fudis-heading>
<fudis-autocomplete-multi-select
<!-- <fudis-autocomplete-multi-select
[label]="'Search and choose items'"
[options]="multipleOptions"
/>
/> -->
</fudis-grid>
</ng-template>
</fudis-expandable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,38 @@ Recommended settings are specified in `settings/.vscode/settings.json`. They ass

Take a look at the file to see all recommendations and commentary about them. You should really use all of them, but here are some of the most important ones:

| Setting | Recommended Value | Description |
| --------------------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `eslint.workingDirectories` | `["ngx-fudis"]` | Enables the ESLint extension to work when VS Code is opened in repository root. Without this setting, interactive linting is available only when VS Code is opened in `ngx-fudis/` directory. |
| `editor.formatOnSave` | `true` | Makes formatting painless as it happens automatically and you never have to think about it. |
<table>
<thead>
<tr>
<th>Setting</th>
<th>Recommended Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code>eslint.workingDirectories</code>
</td>
<td>`["ngx-fudis"]`</td>
<td>
Enables the ESLint extension to work when VS Code is opened in repository root. Without this
setting, interactive linting is available only when VS Code is opened in{" "}
<code>ngx-fudis/</code> directory.
</td>
</tr>
<tr>
<td>
<code>editor.formatOnSave</code>
</td>
<td>
<code>true</code>
</td>
<td>
Makes formatting painless as it happens automatically and you never have to think about it.
</td>
</tr>
</tbody>
</table>

Remember that VS Code applies `.vscode/settings.json` contents only to that folder and its subfolders, so your global configuration will not be affected by using these recommendations.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(handleBlur)="_handleBlur($event)"
[attr.aria-label]="message"
[initialFocus]="initialFocus"
[color]="variant !== 'warning' ? 'white' : 'default'"
[color]="variant !== 'warning' ? 'white' : 'gray'"
class="fudis-alert__link"
*ngIf="routerLinkUrl && linkTitle"
[routerLinkUrl]="routerLinkUrl"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ArgTypes, Meta, Canvas } from "@storybook/blocks";

import { AlertGroupComponent } from "./alert-group/alert-group.component.ts";
import { excludeRegex } from "../../utilities/storybook";

<Meta title="Components/Alert Group" />

Expand Down Expand Up @@ -104,4 +104,6 @@ Fudis Dialog has a focus trap, so that keyboard are not able to navigate outside
- Alert Group is wrapped inside a `section` element which has an automatic `aria-label` describing its content. E. g. 'Notifications - Number of notifications: 5'
- Elements used in Alert Group have proper labels as needed for screen reader users.

## Properties

<ArgTypes of={AlertGroupComponent} />
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { moduleMetadata, StoryFn, Meta } from '@storybook/angular';
import { BreadcrumbsComponent } from './breadcrumbs.component';
import readme from './readme.mdx';
import { breadcrumbsExclude } from '../../utilities/storybook';

export default {
title: 'Components/Breadcrumbs',
Expand All @@ -14,12 +15,14 @@ export default {
parameters: {
docs: {
page: readme,
argTypes: {
exclude: breadcrumbsExclude,
},
},
controls: {
exclude: '_breadcrumbsPrefix',
exclude: breadcrumbsExclude,
},
},
argTypes: {},
} as Meta;

const html = String.raw;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { ArgTypes, Meta, Canvas } from "@storybook/blocks";
import { linkTo } from "@storybook/addon-links";
import { BreadcrumbsComponent } from "./breadcrumbs.component";
import * as BreadcrumbsStories from "./breadcrumbs.stories.ts";
import { breadcrumbsExclude } from "../../utilities/storybook";
import { BreadcrumbsItemComponent } from "./breadcrumbs-item/breadcrumbs-item.component";

<Meta title="Components/Breadcrumbs" />

Expand Down Expand Up @@ -45,6 +46,10 @@ The last Breadcrumbs Item Component is always displayed as non-link and just pla
- Each visible Breadcrumbs Item, except the last one, is a link
- The last visible list item has `aria-current="page"` attribute

## Properties
## Properties of Breadcrumbs

<ArgTypes of={BreadcrumbsComponent} />

## Properties of Breadcrumbs Item

<ArgTypes of={BreadcrumbsItemComponent} exclude={breadcrumbsExclude} />
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { StoryFn, Meta } from '@storybook/angular';
import { ButtonComponent } from './button.component';
import readme from './readme.mdx';
import { buttonExclude } from '../../utilities/storybook';

export default {
title: 'Components/Button',
component: ButtonComponent,
parameters: {
docs: {
argTypes: {
exclude: buttonExclude,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason (similar to Dialog) this didn't work and readme ArgTypes needed the exclude. So I deleted this one and added the exclude in readme.

},
page: readme,
},
controls: {
exclude: ['_iconColor', '_classList', 'getClasses', 'ngOnChanges', 'getAriaLabel'],
exclude: buttonExclude,
},
},
argTypes: {
Expand All @@ -25,6 +29,13 @@ export default {
icon: {
control: { type: 'text' },
},
tooltip: {
control: { type: 'text' },
},
tooltipPosition: {
options: ['left', 'right', 'above', 'below'],
control: { type: 'radio' },
},
},
} as Meta;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ArgTypes, Meta, Canvas, Controls } from "@storybook/blocks";
import { ArgTypes, Meta, Canvas } from "@storybook/blocks";
import { ButtonComponent } from "./button.component";
import * as ButtonStories from "./button.stories.ts";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { linkTo } from "@storybook/addon-links";
import { DescriptionListComponent } from "./description-list.component.ts";
import * as DescriptionListStories from "./description-list.stories.ts";
import { Source } from "@storybook/blocks";
import { excludeRegex } from "../../utilities/storybook";

<Meta title="Components/Description List" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { Component, Input, OnDestroy, OnInit, effect } from '@angular/core';
import { FudisDialogService } from '../../services/dialog/dialog.service';
import { FudisIdService } from '../../services/id/id.service';
import { FudisTranslationService } from '../../services/translation/translation.service';

type DialogSize = 'sm' | 'md' | 'lg' | 'xl' | 'initial';
import { FudisDialogSize } from '../../types/miscellaneous';

@Component({
selector: 'fudis-dialog',
Expand All @@ -25,7 +24,7 @@ export class DialogComponent implements OnInit, OnDestroy {
/**
* Dialog size
*/
@Input() size: DialogSize = 'md';
@Input() size: FudisDialogSize = 'md';

/**
* Dialog's close button has to have absolute positioning when used inside fudis-form
Expand Down
Loading
Loading