diff --git a/.eslintrc.cjs b/.eslintrc.cjs index f6b416d2a..0c88ca2e7 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -31,7 +31,7 @@ module.exports = { customElement: true, }, }, - } + }, ], extends: [ 'eslint:recommended', @@ -44,61 +44,34 @@ module.exports = { 'plugin:sonarjs/recommended', 'plugin:tailwindcss/recommended', 'plugin:storybook/recommended', + 'prettier', ], rules: { // Eslint rules - '@typescript-eslint/indent': ['error', 2], - 'array-bracket-spacing': 'error', 'array-callback-return': 'error', - 'arrow-spacing': 'error', - 'block-spacing': 'error', - 'brace-style': 'error', - 'comma-dangle': ['error', { - arrays: 'always-multiline', - objects: 'always-multiline', - imports: 'always-multiline', - exports: 'never', - functions: 'never', - }], - 'comma-spacing': 'error', - 'computed-property-spacing': 'error', 'dot-notation': 'error', - 'eol-last': 'error', - eqeqeq: ['error', 'always', { - null: 'always', - }], - 'func-call-spacing': 'error', - 'key-spacing': 'error', - 'keyword-spacing': 'error', + eqeqeq: [ + 'error', + 'always', + { + null: 'always', + }, + ], 'no-caller': 'error', - 'no-multi-spaces': 'error', - // https://github.com/sveltejs/eslint-plugin-svelte3/issues/41 - 'no-multiple-empty-lines': 'off', - 'no-multi-spaces': 'error', 'no-param-reassign': 'error', 'no-return-await': 'error', 'no-unreachable-loop': 'error', 'no-unsafe-optional-chaining': 'error', 'nonblock-statement-body-position': 'error', - 'object-curly-spacing': ['error', 'always'], - 'one-var': ['error', { - let: 'never', - const: 'never', - }], - quotes: ['error', 'single', { - avoidEscape: true, - }], + 'one-var': [ + 'error', + { + let: 'never', + const: 'never', + }, + ], 'require-atomic-updates': 'error', - 'rest-spread-spacing': 'error', - semi: ['error', 'always'], - 'semi-spacing': 'error', - 'semi-style': 'error', - 'space-before-blocks': 'error', - 'space-in-parens': 'error', - 'space-infix-ops': 'error', - 'space-unary-ops': 'error', 'spaced-comment': 'error', - 'template-curly-spacing': 'error', radix: 'error', 'require-await': 'error', strict: 'error', @@ -109,11 +82,14 @@ module.exports = { 'prefer-const': 'error', 'prefer-template': 'error', 'require-await': 'error', - 'prefer-arrow/prefer-arrow-functions': ['error', { - disallowPrototype: true, - singleReturnOnly: false, - classPropertiesAllowed: false, - }], + 'prefer-arrow/prefer-arrow-functions': [ + 'error', + { + disallowPrototype: true, + singleReturnOnly: false, + classPropertiesAllowed: false, + }, + ], // Unicorn rules 'unicorn/switch-case-braces': 'off', 'unicorn/no-unsafe-regex': 'error', @@ -158,9 +134,13 @@ module.exports = { 'import/no-cycle': 'error', 'import/no-useless-path-segments': 'error', 'import/export': 'error', - 'import/extensions': ["error", "never", { - "svelte": "always" - }], + 'import/extensions': [ + 'error', + 'never', + { + svelte: 'always', + }, + ], // Do not currently work with eslint-plugin-svelte 'import/first': 'off', 'import/order': 'error', @@ -179,9 +159,9 @@ module.exports = { // always try to resolve types under `@types` directory even it doesn't contain any source code, like `@types/unist` alwaysTryTypes: true, project: './tsconfig.json', - } + }, }, 'svelte3/typescript': () => require('typescript'), }, ignorePatterns: ['**/cypress/**', '**/node_modules/**', '*.json'], -}; \ No newline at end of file +}; diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5c57660c4..fb9b475d8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -34,4 +34,4 @@ jobs: - name: Publish 🚀 uses: JS-DevTools/npm-publish@v1 with: - token: ${{ secrets.NPM_TOKEN }} + token: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/pullrequest.yml b/.github/workflows/pullrequest.yml index dbd94ad40..16f5971aa 100644 --- a/.github/workflows/pullrequest.yml +++ b/.github/workflows/pullrequest.yml @@ -9,42 +9,43 @@ jobs: eslint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install 🔧 - run: npm ci --audit=false - - name: Run ESLint - run: npm run lint + - uses: actions/checkout@v2 + - name: Install 🔧 + run: npm ci --audit=false + - name: Run ESLint and Prettier + run: | + npm run lint + npm run format-check check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install 🔧 - run: npm ci --audit=false - - name: Run Check - run: npm run check + - uses: actions/checkout@v2 + - name: Install 🔧 + run: npm ci --audit=false + - name: Run Check + run: npm run check test: timeout-minutes: 10 runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 16 - - name: Install deps - run: | - npm ci --audit=false - cd playground - npm ci --audit=false - - name: Install Playwright Browsers - run: npx playwright install --with-deps - - name: Run Playwright tests - run: npx playwright test - - uses: actions/upload-artifact@v3 - if: always() - with: - name: playwright-report - path: playwright-report/ - retention-days: 30 - + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Install deps + run: | + npm ci --audit=false + cd playground + npm ci --audit=false + - name: Install Playwright Browsers + run: npx playwright install --with-deps + - name: Run Playwright tests + run: npx playwright test + - uses: actions/upload-artifact@v3 + if: always() + with: + name: playwright-report + path: playwright-report/ + retention-days: 30 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..7c979fb41 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +package-lock.json +dist +prime diff --git a/.prettierrc.cjs b/.prettierrc.cjs new file mode 100644 index 000000000..8dc09940c --- /dev/null +++ b/.prettierrc.cjs @@ -0,0 +1,8 @@ +module.exports = { + plugins: ['prettier-plugin-svelte'], + singleQuote: true, + // TODO(mc, 2023-03-22): eslint-plugin-svelte does not respect single-quote for HTML + // https://github.com/sveltejs/prettier-plugin-svelte/issues/253 + jsxSingleQuote: true, + svelteIndentScriptAndStyle: false, +}; diff --git a/.storybook/main.js b/.storybook/main.js index cebceb2a6..239c29951 100644 --- a/.storybook/main.js +++ b/.storybook/main.js @@ -21,15 +21,15 @@ export default { }, async viteFinal(config) { return mergeConfig(config, { - base: '/' + base: '/', }); }, framework: { name: '@storybook/html-vite', - options: {} + options: {}, }, features: { modernInlineRender: true, storyStoreV7: true, }, -}; \ No newline at end of file +}; diff --git a/.storybook/manager.js b/.storybook/manager.js index 940a72101..41e007d2a 100644 --- a/.storybook/manager.js +++ b/.storybook/manager.js @@ -1,7 +1,7 @@ -import { addons } from '@storybook/addons' -import theme from './theme' +import { addons } from '@storybook/addons'; +import theme from './theme'; addons.setConfig({ theme, enableShortcuts: false, -}) +}); diff --git a/.storybook/preview.js b/.storybook/preview.js index 2275b169a..7ebe2f6e9 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -1,5 +1,5 @@ export const parameters = { - actions: { argTypesRegex: "^on[A-Z].*" }, + actions: { argTypesRegex: '^on[A-Z].*' }, controls: { expanded: true, matchers: { @@ -9,8 +9,8 @@ export const parameters = { }, docs: { source: { - state: 'open' - } + state: 'open', + }, }, inlineStories: true, -} +}; diff --git a/.storybook/theme.js b/.storybook/theme.js index 5cbfcb89d..565459ff6 100644 --- a/.storybook/theme.js +++ b/.storybook/theme.js @@ -1,7 +1,7 @@ -import { create } from '@storybook/theming' +import { create } from '@storybook/theming'; export default create({ brandImage: 'https://www.viam.com/static/logo.svg', fontBase: '"Space mono", sans-serif', appBg: '#333', -}) +}); diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 5eb66780a..c7e300e25 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,7 @@ "csstools.postcss", "bradlc.vscode-tailwindcss", "svelte.svelte-vscode", - "silvenon.mdx" + "unifiedjs.vscode-mdx", + "esbenp.prettier-vscode" ] } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3b8ddc693..61c29be4d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,3 +35,41 @@ More detailed docs exist on [the storybook](https://www.viam.com/prime). Linked below are some articles that provide knowledge for how to best build reusable, generic web components. - [Custom Elements Best Practices](https://web.dev/custom-elements-best-practices/) + +## Development tasks + +To verify that static assets build correctly: + +```shell +npm run build-storybook +``` + +To run tests locally, you must first install the `playground` development dependencies and playwright. From there, you can run tests + +```shell +# set up playground +cd playground +npm install +cd .. +npx playwright install --with-deps + +# run tests, with optional debugging +npm run test +npm run test-dev +``` + +You can typecheck and lint using: + +```shell +# check types, a11y, and other component quality +npm run check + +# autoformat code and documentation +npm run format + +# check formatting without writing files +npm run format-check + +# lint for stylistic and correctness issues +npm run lint +``` diff --git a/README.md b/README.md index 685e2a04e..bc33dbad0 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,14 @@ PRIME is a collection of atomic UI elements, designed to "just work" in any HTML ## Installation The PRIME NPM package contains the following necessary exports for usage: -* `prime.es.js` or `prime.umd.js` - JS that defines custom elements. ES modules are recommended over UMD. -* `prime.css` - stylesheet shared by all elements. + +- `prime.es.js` or `prime.umd.js` - JS that defines custom elements. ES modules are recommended over UMD. +- `prime.css` - stylesheet shared by all elements. If using ES modules, import Prime's JS file into your code: ```ts -import '@viamrobotics/prime' +import '@viamrobotics/prime'; ``` You must host `prime.css` in a static file server. This is every prime element loads it as a shared stylesheet. @@ -26,10 +27,10 @@ If you are not hosting `prime.css` at the root directory of your domain, you wil ```html ``` @@ -37,7 +38,7 @@ If the necessary `.css` and `.js` files have been added, then no additional impo You can immediately start adding PRIME elements to your app, since prime elements are simply custom HTML elements: ```html - + ``` All elements are prefixed with `v-`. This stands for Viam, the cool company where these elements are made. @@ -45,24 +46,30 @@ All elements are prefixed with `v-`. This stands for Viam, the cool company wher ## Playground To use the playground, go to the `playground` directory, and: + ```bash npm install npm start ``` + Or to run in production mode: -``` + +```bash npm run build npm run serve ``` ## Linting / Testing + To lint and typecheck: + ```bash npm run lint npm run check ``` To test: + ```bash npm run test-dev # to test with the playwright debug UI # or @@ -76,11 +83,17 @@ npm run test # for .spec.ts `PRIME` supports the following browsers: -![Chrome](https://github.com/raw/alrra/browser-logos/master/src/chrome/chrome_48x48.png) | ![Firefox](https://github.com/raw/alrra/browser-logos/master/src/firefox/firefox_48x48.png) | ![Edge](https://github.com/raw/alrra/browser-logos/master/src/edge/edge_48x48.png) | ![Safari](https://github.com/raw/alrra/browser-logos/master/src/safari/safari_48x48.png) ---- | --- | --- | --- | -Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | +| ![Chrome][] | ![Firefox][] | ![Edge][] | ![Safari][] | +| ----------- | ------------ | --------- | ----------- | +| Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | + +[chrome]: https://github.com/raw/alrra/browser-logos/master/src/chrome/chrome_48x48.png +[firefox]: https://github.com/raw/alrra/browser-logos/master/src/firefox/firefox_48x48.png +[edge]: https://github.com/raw/alrra/browser-logos/master/src/edge/edge_48x48.png +[safari]: https://github.com/raw/alrra/browser-logos/master/src/safari/safari_48x48.png ## License -Copyright 2021-2022 Viam Inc. + +Copyright 2021-2023 Viam Inc. Apache 2.0 - See [LICENSE](https://github.com/viamrobotics/prime/blob/main/LICENSE) file diff --git a/package-lock.json b/package-lock.json index 84591ee71..7de3dc856 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@viamrobotics/prime", - "version": "0.1.3", + "version": "0.1.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@viamrobotics/prime", - "version": "0.1.3", + "version": "0.1.4", "license": "Apache-2.0", "devDependencies": { "@floating-ui/dom": "^1.0.12", @@ -27,6 +27,7 @@ "classnames": "^2.3.2", "element-internals-polyfill": "^1.1.17", "eslint": "^8.30.0", + "eslint-config-prettier": "^8.8.0", "eslint-import-resolver-typescript": "^3.5.2", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.6.1", @@ -38,6 +39,8 @@ "eslint-plugin-unicorn": "^45.0.2", "monaco-editor": "^0.34.1", "postcss": "^8.4.20", + "prettier": "^2.8.6", + "prettier-plugin-svelte": "^2.9.0", "react": "^18.2.0", "react-dom": "^18.2.0", "storybook": "^7.0.0-beta.13", @@ -6829,6 +6832,18 @@ "url": "https://opencollective.com/eslint" } }, + "node_modules/eslint-config-prettier": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz", + "integrity": "sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==", + "dev": true, + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, "node_modules/eslint-import-resolver-node": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", @@ -11039,9 +11054,9 @@ } }, "node_modules/prettier": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.1.tgz", - "integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==", + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.6.tgz", + "integrity": "sha512-mtuzdiBbHwPEgl7NxWlqOkithPyp4VN93V7VeHVWBF+ad3I5avc0RVDT4oImXQy9H/AqxA2NSQH8pSxHW6FYbQ==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -11053,6 +11068,16 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, + "node_modules/prettier-plugin-svelte": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-2.9.0.tgz", + "integrity": "sha512-3doBi5NO4IVgaNPtwewvrgPpqAcvNv0NwJNflr76PIGgi9nf1oguQV1Hpdm9TI2ALIQVn/9iIwLpBO5UcD2Jiw==", + "dev": true, + "peerDependencies": { + "prettier": "^1.16.4 || ^2.0.0", + "svelte": "^3.2.0" + } + }, "node_modules/pretty-format": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", @@ -19056,6 +19081,13 @@ } } }, + "eslint-config-prettier": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz", + "integrity": "sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA==", + "dev": true, + "requires": {} + }, "eslint-import-resolver-node": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", @@ -22178,11 +22210,18 @@ "dev": true }, "prettier": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.1.tgz", - "integrity": "sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==", + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.6.tgz", + "integrity": "sha512-mtuzdiBbHwPEgl7NxWlqOkithPyp4VN93V7VeHVWBF+ad3I5avc0RVDT4oImXQy9H/AqxA2NSQH8pSxHW6FYbQ==", "dev": true }, + "prettier-plugin-svelte": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-svelte/-/prettier-plugin-svelte-2.9.0.tgz", + "integrity": "sha512-3doBi5NO4IVgaNPtwewvrgPpqAcvNv0NwJNflr76PIGgi9nf1oguQV1Hpdm9TI2ALIQVn/9iIwLpBO5UcD2Jiw==", + "dev": true, + "requires": {} + }, "pretty-format": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", diff --git a/package.json b/package.json index 856712784..b5b840d09 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,9 @@ "serve": "vite preview --host", "check": "svelte-check --tsconfig ./tsconfig.json", "lint": "eslint --ext .ts,.svelte, ./src/elements", + "format": "npm run format-base -- --write", + "format-check": "npm run format-base -- --check", + "format-base": "prettier \"./**/*.@(js|cjs|ts|svelte|md|mdx|yml|json)\"", "test": "npx playwright test", "test-dev": "npx playwright test --debug", "storybook": "storybook dev -p 6006", @@ -49,6 +52,7 @@ "classnames": "^2.3.2", "element-internals-polyfill": "^1.1.17", "eslint": "^8.30.0", + "eslint-config-prettier": "^8.8.0", "eslint-import-resolver-typescript": "^3.5.2", "eslint-plugin-import": "^2.26.0", "eslint-plugin-jsx-a11y": "^6.6.1", @@ -60,6 +64,8 @@ "eslint-plugin-unicorn": "^45.0.2", "monaco-editor": "^0.34.1", "postcss": "^8.4.20", + "prettier": "^2.8.6", + "prettier-plugin-svelte": "^2.9.0", "react": "^18.2.0", "react-dom": "^18.2.0", "storybook": "^7.0.0-beta.13", diff --git a/playground/postcss.config.cjs b/playground/postcss.config.cjs index 08a01d4d1..ee5f90b30 100644 --- a/playground/postcss.config.cjs +++ b/playground/postcss.config.cjs @@ -2,4 +2,4 @@ module.exports = { plugins: { tailwindcss: {}, }, -} +}; diff --git a/playground/src/pages/badge-test.ts b/playground/src/pages/badge-test.ts index c350b29a2..fc8910c79 100644 --- a/playground/src/pages/badge-test.ts +++ b/playground/src/pages/badge-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../badge-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../badge-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/breadcrumb-test.ts b/playground/src/pages/breadcrumb-test.ts index 9033f74ee..7a36fbede 100644 --- a/playground/src/pages/breadcrumb-test.ts +++ b/playground/src/pages/breadcrumb-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../breadcrumb-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../breadcrumb-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/button-test.ts b/playground/src/pages/button-test.ts index 1bfea25ac..f62e0f631 100644 --- a/playground/src/pages/button-test.ts +++ b/playground/src/pages/button-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../button-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../button-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/code-editor-test.ts b/playground/src/pages/code-editor-test.ts index 9a4e302fd..527cd1a58 100644 --- a/playground/src/pages/code-editor-test.ts +++ b/playground/src/pages/code-editor-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../code-editor-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../code-editor-test.vue'; -createApp(App).mount('#app') \ No newline at end of file +createApp(App).mount('#app'); diff --git a/playground/src/pages/collapse-test.ts b/playground/src/pages/collapse-test.ts index 8465dc8b1..bb4670d81 100644 --- a/playground/src/pages/collapse-test.ts +++ b/playground/src/pages/collapse-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../collapse-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../collapse-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/icon-test.ts b/playground/src/pages/icon-test.ts index e9242f8ec..57b090ae1 100644 --- a/playground/src/pages/icon-test.ts +++ b/playground/src/pages/icon-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../icon-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../icon-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/input-test.ts b/playground/src/pages/input-test.ts index 353dd008e..c3e8809fd 100644 --- a/playground/src/pages/input-test.ts +++ b/playground/src/pages/input-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../input-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../input-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/list-box-test.ts b/playground/src/pages/list-box-test.ts index 435b2c15a..949ecc161 100644 --- a/playground/src/pages/list-box-test.ts +++ b/playground/src/pages/list-box-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../list-box-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../list-box-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/main.ts b/playground/src/pages/main.ts index a5de9927f..b714b2cb7 100644 --- a/playground/src/pages/main.ts +++ b/playground/src/pages/main.ts @@ -1,7 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../App.vue' - -createApp(App).mount('#app') +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../App.vue'; +createApp(App).mount('#app'); diff --git a/playground/src/pages/modal-test.ts b/playground/src/pages/modal-test.ts index 4496ba43f..fa200cc36 100644 --- a/playground/src/pages/modal-test.ts +++ b/playground/src/pages/modal-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../modal-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../modal-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/multi-select-test.ts b/playground/src/pages/multi-select-test.ts index bcd272e34..cb6217acc 100644 --- a/playground/src/pages/multi-select-test.ts +++ b/playground/src/pages/multi-select-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../multi-select-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../multi-select-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/notify-test.ts b/playground/src/pages/notify-test.ts index 65529d10a..1f101c8be 100644 --- a/playground/src/pages/notify-test.ts +++ b/playground/src/pages/notify-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../notify-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../notify-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/pill-test.ts b/playground/src/pages/pill-test.ts index 2db2620c3..a006b7d3f 100644 --- a/playground/src/pages/pill-test.ts +++ b/playground/src/pages/pill-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../pill-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../pill-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/radio-test.ts b/playground/src/pages/radio-test.ts index f05c669ba..ad46f5c10 100644 --- a/playground/src/pages/radio-test.ts +++ b/playground/src/pages/radio-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../radio-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../radio-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/select-test.ts b/playground/src/pages/select-test.ts index 4e8d19cc8..9f89c231a 100644 --- a/playground/src/pages/select-test.ts +++ b/playground/src/pages/select-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../select-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../select-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/slider-test.ts b/playground/src/pages/slider-test.ts index 0a30de47b..aae86d7b6 100644 --- a/playground/src/pages/slider-test.ts +++ b/playground/src/pages/slider-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../slider-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../slider-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/switch-test.ts b/playground/src/pages/switch-test.ts index 10e6434f8..1f9ca2cb0 100644 --- a/playground/src/pages/switch-test.ts +++ b/playground/src/pages/switch-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../switch-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../switch-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/tabs-test.ts b/playground/src/pages/tabs-test.ts index cc7441526..eebc41340 100644 --- a/playground/src/pages/tabs-test.ts +++ b/playground/src/pages/tabs-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../tabs-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../tabs-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/src/pages/vector-input-test.ts b/playground/src/pages/vector-input-test.ts index b2acb6851..68c10b1f3 100644 --- a/playground/src/pages/vector-input-test.ts +++ b/playground/src/pages/vector-input-test.ts @@ -1,6 +1,6 @@ -import './main.css' -import '../../../src/main' -import { createApp } from 'vue' -import App from '../vector-input-test.vue' +import './main.css'; +import '../../../src/main'; +import { createApp } from 'vue'; +import App from '../vector-input-test.vue'; -createApp(App).mount('#app') +createApp(App).mount('#app'); diff --git a/playground/tailwind.config.cjs b/playground/tailwind.config.cjs index 3eaefddf5..2c5fec85d 100644 --- a/playground/tailwind.config.cjs +++ b/playground/tailwind.config.cjs @@ -1,5 +1,5 @@ -const plugin = require('tailwindcss/plugin') -const { theme } = require('../tailwind.config.cjs') +const plugin = require('tailwindcss/plugin'); +const { theme } = require('../tailwind.config.cjs'); module.exports = { content: ['./index.html', './src/**/*.{ts,vue}', '../src/**/*.{ts,svelte}'], @@ -7,4 +7,4 @@ module.exports = { variants: { extend: {}, }, -} +}; diff --git a/playground/vite.config.ts b/playground/vite.config.ts index 9d8e610ca..246c7f08b 100644 --- a/playground/vite.config.ts +++ b/playground/vite.config.ts @@ -1,8 +1,8 @@ -import { defineConfig } from 'vite' -import { fileURLToPath } from 'url' -import vue from '@vitejs/plugin-vue' -import { svelte } from '@sveltejs/vite-plugin-svelte' -import sveltePreprocess from 'svelte-preprocess' +import { defineConfig } from 'vite'; +import { fileURLToPath } from 'url'; +import vue from '@vitejs/plugin-vue'; +import { svelte } from '@sveltejs/vite-plugin-svelte'; +import sveltePreprocess from 'svelte-preprocess'; // https://vitejs.dev/config/ export default defineConfig({ @@ -33,5 +33,5 @@ export default defineConfig({ test: fileURLToPath(new URL('./test.html', import.meta.url)), }, }, - } -}) + }, +}); diff --git a/playwright.config.ts b/playwright.config.ts index 93d5770a0..1e665f567 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -19,7 +19,7 @@ const config: PlaywrightTestConfig = { * Maximum time expect() should wait for the condition to be met. * For example in `await expect(locator).toHaveText();` */ - timeout: 5000 + timeout: 5000, }, /* Run tests in files in parallel */ fullyParallel: true, diff --git a/postcss.config.cjs b/postcss.config.cjs index 08a01d4d1..ee5f90b30 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -2,4 +2,4 @@ module.exports = { plugins: { tailwindcss: {}, }, -} +}; diff --git a/scripts/postbuild.js b/scripts/postbuild.js index de7632ccd..2907e863d 100644 --- a/scripts/postbuild.js +++ b/scripts/postbuild.js @@ -1,15 +1,15 @@ -import pkg from '../package.json' assert { type: 'json' } -import { rename, copy, write, read } from './util.js' -import { minify } from 'terser' +import pkg from '../package.json' assert { type: 'json' }; +import { rename, copy, write, read } from './util.js'; +import { minify } from 'terser'; -const { version } = pkg +const { version } = pkg; const compress = async (file) => { const minified = await minify(file, { ecma: 2020, module: true, parse: { - html5_comments: false + html5_comments: false, }, compress: { drop_console: true, @@ -18,12 +18,12 @@ const compress = async (file) => { unsafe: true, }, format: { - comments: false + comments: false, }, - }) + }); - return minified.code -} + return minified.code; +}; const main = async () => { /** @@ -31,47 +31,51 @@ const main = async () => { */ // Rename our stylesheets to what the web components reference - rename('dist/style.css', 'dist/prime.css') + rename('dist/style.css', 'dist/prime.css'); // Add Typescript definitions to the library directory - copy('src/prime.d.ts', 'dist/prime.d.ts') + copy('src/prime.d.ts', 'dist/prime.d.ts'); // Add icon resources - copy('public/icons.woff2', 'dist/icons.woff2') + copy('public/icons.woff2', 'dist/icons.woff2'); // Update icons path { - const file = read('dist/prime.css') - .replace(/.\/icons.woff2/, 'icons.woff2') - write('dist/prime.css', file) + const file = read('dist/prime.css').replace( + /.\/icons.woff2/, + 'icons.woff2' + ); + write('dist/prime.css', file); } // Create versioned resources for consumers with cache-busting - copy('dist/prime.es.js', `dist/prime@${version}.es.js`) - copy('dist/prime.umd.js', `dist/prime@${version}.umd.js`) - copy('dist/prime.css', `dist/prime@${version}.css`) - copy('dist/icons.woff2', `dist/icons@${version}.woff2`) + copy('dist/prime.es.js', `dist/prime@${version}.es.js`); + copy('dist/prime.umd.js', `dist/prime@${version}.umd.js`); + copy('dist/prime.css', `dist/prime@${version}.css`); + copy('dist/icons.woff2', `dist/icons@${version}.woff2`); // Update paths for versioned resources { - const file = read(`dist/prime@${version}.css`) - .replace(/icons.woff2/, `icons@${version}.woff2'`) - write(`dist/prime@${version}.css`, file) + const file = read(`dist/prime@${version}.css`).replace( + /icons.woff2/, + `icons@${version}.woff2'` + ); + write(`dist/prime@${version}.css`, file); } { const file = read(`dist/prime@${version}.es.js`) .replace(/"\/prime.css"/g, `"/prime@${version}.css"`) - .replace(/"\/icons.css"/g, `"/icons@${version}.css"`) - write(`dist/prime@${version}.es.js`, file) - write(`dist/prime@${version}.min.es.js`, await compress(file)) + .replace(/"\/icons.css"/g, `"/icons@${version}.css"`); + write(`dist/prime@${version}.es.js`, file); + write(`dist/prime@${version}.min.es.js`, await compress(file)); } { const file = read(`dist/prime@${version}.umd.js`) .replace(/"\/prime.css"/g, `"/prime@${version}.css"`) - .replace(/"\/icons.css"/g, `"/icons@${version}.css"`) - write(`dist/prime@${version}.umd.js`, file) + .replace(/"\/icons.css"/g, `"/icons@${version}.css"`); + write(`dist/prime@${version}.umd.js`, file); } /** @@ -79,26 +83,31 @@ const main = async () => { */ // Disable Jekyll when deploying to gh-pages - write('prime/.nojekyll', '') + write('prime/.nojekyll', ''); // Move assets to the storybook directory - copy('dist/prime.es.js', 'prime/prime.es.js') - copy('dist/prime.css', 'prime/prime.css') - copy('dist/icons.woff2', 'prime/icons.woff2') + copy('dist/prime.es.js', 'prime/prime.es.js'); + copy('dist/prime.css', 'prime/prime.css'); + copy('dist/icons.woff2', 'prime/icons.woff2'); { const file = read('prime/index.html') // Add noindex rule - .replace('', '') - write('prime/index.html', file) + .replace( + '', + '' + ); + write('prime/index.html', file); } // Update correct paths for iframe resources { - const file = read('prime/iframe.html') - .replace('', '') - write('prime/iframe.html', file) + const file = read('prime/iframe.html').replace( + '', + '' + ); + write('prime/iframe.html', file); } -} +}; -main() +main(); diff --git a/scripts/util.js b/scripts/util.js index fec46e1ac..2cbbc4dfd 100644 --- a/scripts/util.js +++ b/scripts/util.js @@ -1,8 +1,8 @@ -import fs from 'node:fs' +import fs from 'node:fs'; -export const rename = (src, dest) => fs.renameSync(src, dest) -export const copy = (src, dest) => fs.copyFileSync(src, dest) -export const write = (path, data) => fs.writeFileSync(path, data, 'utf-8') -export const read = (path) => fs.readFileSync(path, 'utf-8') -export const mkdir = (path) => fs.mkdirSync(path) -export const readDir = (path) => fs.readdirSync(path) +export const rename = (src, dest) => fs.renameSync(src, dest); +export const copy = (src, dest) => fs.copyFileSync(src, dest); +export const write = (path, data) => fs.writeFileSync(path, data, 'utf-8'); +export const read = (path) => fs.readFileSync(path, 'utf-8'); +export const mkdir = (path) => fs.mkdirSync(path); +export const readDir = (path) => fs.readdirSync(path); diff --git a/src/elements/badge.svelte b/src/elements/badge.svelte index 1e6394fdd..2c32cb7c0 100644 --- a/src/elements/badge.svelte +++ b/src/elements/badge.svelte @@ -1,8 +1,7 @@ - + - - - { label } + + {label} diff --git a/src/elements/breadcrumbs.svelte b/src/elements/breadcrumbs.svelte index 0e506b0e8..a13275c3f 100644 --- a/src/elements/breadcrumbs.svelte +++ b/src/elements/breadcrumbs.svelte @@ -1,7 +1,6 @@ - - -
{#each parsedCrumbs as crumb, index (crumb)} - { crumb } + {crumb} {#if index !== parsedCrumbs.length - 1}
-
-
+
+
{/if} {/each} diff --git a/src/elements/button/button.svelte b/src/elements/button/button.svelte index 2d7b38076..0fe43425f 100644 --- a/src/elements/button/button.svelte +++ b/src/elements/button/button.svelte @@ -1,12 +1,17 @@ - - - - - { {type} aria-label={variant === 'icon' ? label : undefined} aria-disabled={isDisabled ? true : undefined} - title={title} - class={cx('will-change-transform hover:scale-105 motion-safe:transition-transform', { - 'inline-flex items-center justify-center gap-1.5 py-1.5 px-2 text-xs border': variant !== 'icon', - 'bg-white border-gray-9': variant === 'primary', - 'bg-gray-9 border-gray-9 text-white': variant === 'inverse-primary', - 'bg-danger-fg text-white border-danger-fg': variant === 'danger', - 'bg-success-fg border-success-fg text-white': variant === 'success', - 'bg-danger-bg border-danger-bg text-danger-fg': variant === 'outline-danger', - '!bg-disabled-bg border-disabled-bg text-disabled-fg pointer-events-none select-none': isDisabled, - })} + {title} + class={cx( + 'will-change-transform hover:scale-105 motion-safe:transition-transform', + { + 'inline-flex items-center justify-center gap-1.5 py-1.5 px-2 text-xs border': + variant !== 'icon', + 'bg-white border-gray-9': variant === 'primary', + 'bg-gray-9 border-gray-9 text-white': variant === 'inverse-primary', + 'bg-danger-fg text-white border-danger-fg': variant === 'danger', + 'bg-success-fg border-success-fg text-white': variant === 'success', + 'bg-danger-bg border-danger-bg text-danger-fg': + variant === 'outline-danger', + '!bg-disabled-bg border-disabled-bg text-disabled-fg pointer-events-none select-none': + isDisabled, + } + )} style={isDisabled ? '-webkit-user-select: none' : ''} on:click={handleClick} > {#if icon} -