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

[refactor] #514: Component Story Format 3.0 #520

Open
wants to merge 47 commits into
base: fresh-breath
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4d83e46
[refactor] stories: rewrite `Alert`
0x009922 Mar 14, 2023
634c473
[chore]: update configs
0x009922 Mar 14, 2023
d4d2677
[refactor] stories: rewrite `Badge`
0x009922 Mar 14, 2023
513d406
[refactor] stories: rewrite `Checkbox`
0x009922 Mar 14, 2023
53db760
[refactor] stories: remove `JsonInput` story
0x009922 Mar 14, 2023
551eaba
[refactor] stories: rewrite `Button`
0x009922 Mar 14, 2023
1cc2ae8
[refactor] stories: use `inline-radio` everywhere
0x009922 Mar 14, 2023
31297d7
[refactor] stories: rewrite `TextField`
0x009922 Mar 14, 2023
5c63d10
[refactor] stories: rewrite `Pagination`
0x009922 Mar 20, 2023
c07984a
[chore]: fix root-level SB dev script
0x009922 Mar 20, 2023
21c76a6
[refactor] stories: rewrite `ProgressBar`
0x009922 Mar 20, 2023
e116234
[refactor] stories: adopt `Table`
0x009922 Mar 20, 2023
09ca996
[refactor]: rewrite `Tabs` stories; fix components
0x009922 Mar 20, 2023
28e136f
[refactor]: rewrite `Switch` stories and update the component
0x009922 Mar 20, 2023
8ccb490
[refactor] stories: rewrite `notifications`
0x009922 Mar 20, 2023
84605c0
[refactor] stories: rewrite `Spinner`
0x009922 Mar 20, 2023
3fde037
[refactor] stories: rewrite `Link`
0x009922 Mar 20, 2023
5f2645f
[refactor] stories: rewrite `RadioGroup`
0x009922 Mar 20, 2023
b71d960
[refactor] stories: rewrite `DatePicker`
0x009922 Mar 20, 2023
1975b2c
[refactor] stories: rewrite `NavigationMenu`
0x009922 Mar 20, 2023
29d4898
[chore]: format
0x009922 Mar 20, 2023
6f8342e
[refactor] stories: rewrite `Tooltip`
0x009922 Mar 21, 2023
4417e4c
[refactor] stories: rewrite `Select`, review API
0x009922 Mar 21, 2023
8aefd9e
[test] `SSwitch`: update component tests
0x009922 Mar 21, 2023
d4aa6c3
Merge branch '512-stricter-type-script' into 514-csf-3
0x009922 Mar 21, 2023
8346bda
[chore]: format
0x009922 Mar 21, 2023
3f5e8c6
[refactor] stories: rewrite `Accordion`
0x009922 Mar 21, 2023
fe30447
[refactor] stories: rewrite `Modal`
0x009922 Mar 21, 2023
19a29a2
Merge branch 'fresh-breath' into 514-csf-3
0x009922 Mar 27, 2023
2639964
[refactor]: enable `vue/require-default-prop`
0x009922 Mar 27, 2023
06ec61e
[fix]: configure `vuejs-accessibility/label-has-for`
0x009922 Mar 27, 2023
383eb3a
[chore]: delay fixing, link issue #525
0x009922 Mar 27, 2023
b0f654c
[fix]: ignore a11y rule, add comment; link issues for the future
0x009922 Mar 27, 2023
bfbee09
[refactor]: ~~`useConditionalScope`~~ `useParamScope`
0x009922 Mar 27, 2023
c658d6c
Merge pull request #529 from soramitsu/513-enable-eslint-rules
0x009922 Mar 28, 2023
c47b27b
Merge pull request #530 from soramitsu/use-vue-kakuyaku
0x009922 Mar 28, 2023
adb8d38
[chore]: update build deps
0x009922 Mar 28, 2023
1209e99
[refactor]: rm `@vue/compiler-core`, use `vue/compiler-sfc`
0x009922 Mar 28, 2023
8c5726b
[fix]: `pnpm i --fix-lockfile`
0x009922 Mar 28, 2023
5e9fdfd
[build]: use specifically `[email protected]`
0x009922 Mar 28, 2023
c0e1928
Merge remote-tracking branch 'origin/fresh-breath' into 514-csf-3
0x009922 May 2, 2023
423e5c0
Merge branch 'fresh-breath' into 514-csf-3
0x009922 May 2, 2023
9a66c6e
Merge branch 'fresh-breath' into 514-csf-3
0x009922 May 2, 2023
e3194d7
[chore]: update core dev deps, use released Storybook
0x009922 May 2, 2023
81276e8
Merge remote-tracking branch 'origin/514-csf-3' into 514-csf-3
0x009922 May 2, 2023
d51d63c
[refactor]: use TS for storybook configs
0x009922 May 2, 2023
ea95d06
[revert]: use `[email protected]`
0x009922 May 2, 2023
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
5 changes: 5 additions & 0 deletions .changeset/curvy-moose-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soramitsu-ui/ui': patch
---

**fix**(`STabsPanel`): fix `background` reactivity in the provided `TabsPanelApi`
5 changes: 5 additions & 0 deletions .changeset/good-eels-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soramitsu-ui/ui': patch
---

**fix**(`STab`): don't destructure reactive `TabsPanelApi`
5 changes: 5 additions & 0 deletions .changeset/quiet-badgers-beg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soramitsu-ui/ui': patch
---

**refactor**(`STextField`, `SSwitch`, `SUseNotification`, `SNotificationBody`, `SModal`, `SModalCard`, `SAlert`): set default values for optional props
5 changes: 5 additions & 0 deletions .changeset/quiet-ghosts-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soramitsu-ui/ui': minor
---

**feature**(`SSwitch`): add `label-hidden` optional bool prop in order to _visually_ hide the `label` (`false` by default); update doc comments
5 changes: 5 additions & 0 deletions .changeset/spicy-rivers-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soramitsu-ui/ui': minor
---

**feature**(`STextField`, `SSwitch`): use auto-generated `id` if not provided
5 changes: 5 additions & 0 deletions .changeset/tricky-seas-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soramitsu-ui/ui': patch
---

**perf**(`STextField`): use `computedEager` for cheap computeds; use `shallowRef` instead of `ref`
5 changes: 5 additions & 0 deletions .changeset/warm-zebras-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soramitsu-ui/ui': minor
---

**refactor!**(`STabsPanel`): use passive `model-value`; allow it to be `null`
53 changes: 37 additions & 16 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ module.exports = {

'@typescript-eslint/consistent-type-definitions': 'off',

// FIXME
'vue/require-default-prop': 'off',

// FIXME
'vuejs-accessibility/no-static-element-interactions': 'off',
'vuejs-accessibility/label-has-for': [
'error',
{
// all labels should have `for` attr
required: 'id',
},
],
},
overrides: [
{
Expand All @@ -43,38 +45,57 @@ module.exports = {
files: ['**/packages/ui/**/*.{ts,vue,js}'],
extends: ['./packages/ui/.eslintrc-auto-import.json'],
},
{
files: ['**/*.spec.{js,ts}'],
env: {
jest: true,
},
},

// It is OK to define a lot of components in stories or tests
{
files: ['**/packages/ui/stories/**/*.stories.ts', '**/*.cy.{js,ts}'],
rules: {
// It is OK to define a lot of components in stories or tests
'vue/one-component-per-file': 'off',

// We don't need such strictness in stories
'vue/require-prop-types': 'off',
},
},
{
files: ['**/*.spec.ts', '**/*.spec.cy.ts'],
rules: {
'max-nested-callbacks': 'off',

// We don't need such strictness in tests
'vue/require-default-prop': 'off',
'vue/require-prop-types': 'off',
},
},

// FIXME - temporary disables to fix them in a different PRs
{
files: ['**/ui/src/components/Select/**/*.vue'],
rules: {
// FIXME https://github.com/soramitsu/soramitsu-js-ui-library/issues/525
'vuejs-accessibility/click-events-have-key-events': 'off',
'vuejs-accessibility/no-static-element-interactions': 'off',
},
},

{
files: ['**/ui/src/components/DatePicker/**/*.vue'],
rules: {
// FIXME https://github.com/soramitsu/soramitsu-js-ui-library/issues/526
'vuejs-accessibility/no-static-element-interactions': 'off',
},
},

{
files: ['**/ui/src/components/Table/**/*.vue'],
rules: {
// FIXME https://github.com/soramitsu/soramitsu-js-ui-library/issues/527
'vuejs-accessibility/no-static-element-interactions': 'off',
},
},

// FIXME https://github.com/soramitsu/soramitsu-js-ui-library/issues/528
{
files: ['**/STextField.vue', '**/SSwitch.vue'],
files: ['**/ui/src/components/JsonInput/**/*.vue'],
rules: {
'vuejs-accessibility/label-has-for': 'off',
'vuejs-accessibility/no-static-element-interactions': 'off',
},
},
],
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"license": "Apache-2.0",
"scripts": {
"sb:serve": "pnpm --filter ui sb:serve",
"sb:dev": "pnpm --filter ui sb:dev",
"sb:build": "pnpm --filter ui sb:build",
"test:all": "run-s lint:check test:theme:unit build:vite-plugin-svg test:ui:unit test:ui:cy build:ui:only-vite test:ui:after-build",
"test:theme:unit": "pnpm --filter theme test",
Expand Down Expand Up @@ -44,8 +44,8 @@
"prettier": "^2.6.2",
"prettier-eslint": "^15.0.0",
"prettier-eslint-cli": "^7.1.0",
"typescript": "5.0.2",
"vite": "^4.1.4",
"vitest": "^0.29.2"
"typescript": "5.0.4",
"vite": "^4.3.4",
"vitest": "^0.30.1"
}
}
14 changes: 0 additions & 14 deletions packages/ui/.storybook/main.js

This file was deleted.

19 changes: 19 additions & 0 deletions packages/ui/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { StorybookConfig } from '@storybook/vue3-vite'

export default {
stories: [
{
directory: '../stories/components',
titlePrefix: 'Components',
files: '**/*.stories.@(js|jsx|ts|tsx)',
},
],
addons: ['@storybook/addon-links', '@storybook/addon-essentials', '@storybook/addon-interactions'],
framework: {
name: '@storybook/vue3-vite',
options: {},
},
docs: {
autodocs: 'tag',
},
} satisfies StorybookConfig
3 changes: 0 additions & 3 deletions packages/ui/.storybook/preview-head.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import type { Preview } from '@storybook/vue3'

import 'virtual:windi.css'
import './custom.scss'

/** @type { import('@storybook/vue3').Preview } */
const preview = {
export default {
parameters: {
backgrounds: {
default: 'light',
},
actions: { argTypesRegex: '^on[A-Z].*' },
controls: {
matchers: {
Expand All @@ -15,6 +13,4 @@ const preview = {
},
},
},
}

export default preview
} satisfies Preview
65 changes: 37 additions & 28 deletions packages/ui/cypress/component/SSwitch.spec.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,58 @@ after(() => {
VueTestUtils.config.global.components = {}
})

it('SSwitch - renders with specified label', () => {
cy.mount(SSwitch, { props: { id: 'id', label: 'Label' } })
describe('SSwitch', () => {
it('renders with specified label', () => {
cy.mount(SSwitch, { props: { label: 'Label' } })

cy.contains('Label')
})
cy.contains('Label')
})

it('SSwitch - renders unchecked switch by default', () => {
cy.mount(SSwitch, { props: { id: 'id' } })
it('renders unchecked switch by default', () => {
cy.mount(SSwitch, { props: { label: 'Test' } })

cy.get('input').should('be.not.checked')
})
cy.get('input').should('be.not.checked')
})

it('SSwitch - renders disabled switch when prop is passed', () => {
cy.mount(SSwitch, { props: { id: 'id', disabled: true } })
it('renders disabled switch when prop is passed', () => {
cy.mount(SSwitch, { props: { label: 'Test', disabled: true } })

cy.get('input').should('be.disabled')
})
cy.get('input').should('be.disabled')
})

it('SSwitch - handles two-way data binding and rises value up', () => {
cy.mount({
setup() {
const checked = ref(false)
it('handles two-way data binding and rises value up', () => {
cy.mount({
setup() {
const checked = ref(false)

return { checked }
},
template: `
return { checked }
},
template: `
<div class="switch">{{ checked }}</div>
<SSwitch
id="id"
v-model="checked"
label="Label"
/>
`,
})

cy.contains('Label').click()
cy.get('.switch').contains('true')
})

cy.contains('Label').click()
cy.get('.switch').contains('true')
})
describe('a11y', () => {
beforeEach(() => {
cy.injectAxeAndConfigureCTDefaults()
})

it('SSwitch - has the same id for linking label with input element', () => {
const id = 'identificator'
cy.mount(SSwitch, { props: { id } })
it('SSwitch - a11y check with visible label', () => {
cy.mount(SSwitch, { props: { label: 'Test' } })
cy.checkA11y()
})

cy.get('input').should('have.id', id)
cy.get('label').should('have.attr', 'for', id)
it('SSwitch - a11y check with hidden label', () => {
cy.mount(SSwitch, { props: { label: 'Test', labelHidden: true } })
cy.checkA11y()
})
})
})
40 changes: 20 additions & 20 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
},
"dependencies": {
"@popperjs/core": "^2.10",
"@vue-kakuyaku/core": "^0.4",
"@vueuse/core": "^9.13",
"@vueuse/math": "^9.13",
"date-fns": "^2.29",
Expand All @@ -52,44 +53,43 @@
"@soramitsu-ui/icons": "0.1.0",
"@soramitsu-ui/theme": "0.3.0",
"@soramitsu-ui/vite-plugin-svg": "0.1.0",
"@storybook/addon-actions": "7.0.0-beta.62",
"@storybook/addon-essentials": "7.0.0-beta.62",
"@storybook/addon-interactions": "^7.0.0-beta.62",
"@storybook/addon-links": "7.0.0-beta.62",
"@storybook/blocks": "^7.0.0-beta.62",
"@storybook/cli": "7.0.0-beta.62",
"@storybook/testing-library": "^0.0.14-next.1",
"@storybook/vue3": "7.0.0-beta.62",
"@storybook/vue3-vite": "^7.0.0-beta.62",
"@storybook/addon-actions": "7.0.7",
"@storybook/addon-essentials": "7.0.7",
"@storybook/addon-interactions": "^7.0.7",
"@storybook/addon-links": "7.0.7",
"@storybook/blocks": "^7.0.7",
"@storybook/cli": "7.0.7",
"@storybook/testing-library": "^0.1.0",
"@storybook/vue3": "7.0.7",
"@storybook/vue3-vite": "^7.0.7",
"@types/body-scroll-lock": "^3.1.0",
"@types/jsoneditor": "^9.9.0",
"@types/lodash-es": "^4.17.6",
"@vitejs/plugin-vue": "^4.0.0",
"@vitejs/plugin-vue-jsx": "^3.0.0",
"@vue/compiler-core": "^3.2",
"@vue/test-utils": "^2",
"@vitejs/plugin-vue": "^4.2.1",
"@vitejs/plugin-vue-jsx": "^3.0.1",
"@vue/test-utils": "^2.3.2",
"axe-core": "^4.4.1",
"body-scroll-lock": "^4.0.0-beta.0",
"cypress": "^12.7.0",
"cypress": "^12.11.0",
"cypress-axe": "^1.0.0",
"happy-dom": "^8.9.0",
"immer": "^9.0.19",
"postcss": "^8.4.16",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rollup": "^3.18.0",
"rollup-plugin-dts": "^5.2.0",
"rollup": "^3.20.2",
"rollup-plugin-dts": "^5.3.0",
"sass": "^1.41.1",
"storybook": "^7.0.0-beta.62",
"storybook": "^7.0.7",
"tabbable": "^6.0.0",
"ts-pattern": "^4.2.1",
"typescript": "5.0.2",
"typescript": "5.0.4",
"unimport": "^3.0.2",
"unplugin-auto-import": "^0.15.1",
"unplugin-icons": "^0.15.3",
"vite": "^4.1.4",
"vite": "^4.3.4",
"vite-plugin-windicss": "^1.8.10",
"vue-tsc": "^1.2.0",
"vue-tsc": "1.2",
"windicss": "^3.5.4"
}
}
1 change: 1 addition & 0 deletions packages/ui/src/components/Accordion/SAccordionItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const props = withDefaults(

const emit = defineEmits<(event: 'update:modelValue', value: boolean) => void>()

// FIXME replace with useVModel-passive?
const model = ref(props.modelValue)
watch(
() => props.modelValue,
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/Alert/SAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ type Props = {
const props = withDefaults(defineProps<Props>(), {
status: Status.Info,
showCloseBtn: false,
title: undefined,
description: undefined,
})

const emit = defineEmits<(event: 'click:close') => void>()
Expand Down
Loading