Skip to content

Commit 6ee2964

Browse files
committed
feat: complete rework
- Updated to storybook 3 and new format. Conversion to using $props still pending. - Made esm only (technically breaking change but it wasn't really working before as a hybrid package either and this is still a WIP). - Rewrote most components. - Converted to tailwind. - Changed to use variables from new theming library. - Completely reworked css state management. - Separated out components into smaller easy to re-use building blocks. - Created single global resize observer. - Added a color picker. - Added a popup wrapper component. - Added a template for stories. - Improved accessibility. - Removed babel. - Not sure why even just transforms without polyfills causes issues when using the package, but it shouldn't be a problem to leave the polyfilling to the end app.
1 parent affce5b commit 6ee2964

File tree

106 files changed

+5720
-3916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+5720
-3916
lines changed

.eslintrc.cjs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
const path = require("path")
2-
3-
41
module.exports = {
52
root: true,
63
extends: [
74
// https://github.com/AlansCodeLog/eslint-config
85
"@alanscodelog/eslint-config/vue",
9-
"plugin:storybook/recommended"
6+
"plugin:storybook/recommended",
7+
"plugin:tailwindcss/recommended"
108
],
9+
settings: {
10+
tailwindcss: {
11+
// classRegex: "^(data|type|outlined)(.*)?$",
12+
}
13+
},
1114
// for vscode, so it doesn't try to lint files in here when we open them
1215
ignorePatterns: [
1316
"coverage",
@@ -19,19 +22,19 @@ module.exports = {
1922
parser: "vue-eslint-parser",
2023
parserOptions: {
2124
parser: "@typescript-eslint/parser",
22-
project: "tsconfig.json",
25+
project: "tsconfig.eslint.json",
2326
extraFileExtensions: ['.vue'], //fixes eslint not linting vue files
2427
// debugLevel: true,
2528
},
2629
rules: {
30+
"@typescript-eslint/unified-signatures": "off",
31+
"jsdoc/newline-after-description": "off",
32+
"tailwindcss/no-custom-classname": "off",
33+
"@typescript-eslint/explicit-function-return-type": "off",
34+
"import/no-namespace": "off",
35+
"no-restricted-imports":"off"
2736
},
2837
overrides: [
29-
{
30-
files: ["./*.{js,cjs,ts,vue}"],
31-
rules: {
32-
"@typescript-eslint/explicit-function-return-type": "off",
33-
}
34-
}
3538
// Eslint: https://eslint.org/docs/rules/
3639
// Typescript: https://typescript-eslint.io/rules/
3740
// Vue: https://eslint.vuejs.org/rules/

.github/workflows/build-only.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
node-version: ["lts/-2", "latest"]
19+
node-version: ["lts/-1", "latest"]
2020

2121
steps:
2222

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
runs-on: ubuntu-latest
2222
strategy:
2323
matrix:
24-
node-version: ["lts/-2", "latest"]
24+
node-version: ["lts/-1", "latest"]
2525

2626
steps:
2727

.github/workflows/release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
node-version: ["lts/-2"]
19+
node-version: ["lts/-1"]
2020

2121
steps:
2222

@@ -70,7 +70,8 @@ jobs:
7070
env:
7171
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7272
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
73-
run: npx semantic-release
73+
# https://github.com/semantic-release/semantic-release/blob/master/docs/support/node-version.md
74+
run: npx -p node@v18-lts -c semantic-release
7475

7576
- run: echo "env.ENABLE_RELEASE is ${{ env.ENABLE_RELEASE }}, no release can be published" && exit 1
7677
if: "env.ENABLE_RELEASE != 'true'"

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ worktree*/**/*
66
docs
77
coverage
88
dist
9+
10+
src/assets/variables.scss
11+
**/*.wip.*
12+
test.css

.storybook/main.ts

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11

2+
import {mergeConfig} from "vite"
23
export default {
3-
"stories": [
4-
"../src/**/*.stories.mdx",
5-
"../src/**/*.stories.@(js|jsx|ts|tsx)"
6-
],
7-
"addons": [
8-
"@storybook/addon-links",
9-
"@storybook/addon-essentials"
10-
// "@storybook/addon-a11y"
11-
],
12-
13-
"framework": "@storybook/vue3-vite",
14-
core: {
15-
builder: "@storybook/builder-vite"
16-
},
17-
docsPage: {
18-
docs: "automatic"
19-
},
20-
async viteFinal(config, { configType }) {
21-
// remove babel plugin used in build
22-
const index = config.plugins.findIndex(plugin => plugin.name=== "babel")
23-
config.plugins.splice(index, 1)
24-
return config;
25-
},
4+
"stories": [
5+
// "../src/**/*.stories.mdx",
6+
"../src/**/*.stories.@(js|jsx|ts|tsx)"
7+
],
8+
"addons": [
9+
"@storybook/addon-links",
10+
"@storybook/addon-essentials",
11+
"@storybook/addon-a11y",
12+
"@storybook/addon-storysource",
13+
"storybook-tailwind-dark-mode"
14+
],
15+
"framework": {
16+
name: "@storybook/vue3-vite",
17+
options: {}
18+
},
19+
docsPage: {
20+
docs: "automatic"
21+
},
22+
async viteFinal(config) {
23+
return mergeConfig(config, {
24+
});
25+
},
26+
docs: {
27+
autodocs: true
28+
}
2629
};

.storybook/preview.ts

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,56 @@
1-
export const parameters = {
1+
import { Preview,Parameters } from '@storybook/vue3';
2+
import TestWrapper from "../src/TestWrapper.vue"
3+
import {extractRootEl} from "../src/directives/extractRootEl.js"
4+
import "../src/assets/style.css"
5+
6+
import { library } from "@fortawesome/fontawesome-svg-core"
7+
import { far } from "@fortawesome/free-regular-svg-icons"
8+
import { fas } from "@fortawesome/free-solid-svg-icons"
9+
library.add(fas, far)
10+
11+
export const parameters:Parameters = {
212
actions: { argTypesRegex: "^on[A-Z].*" },
313
controls: {
4-
matchers: {
5-
color: /(background|color)$/i,
6-
date: /Date$/,
7-
},
14+
controls: { expanded: true },
815
},
916
layout: "fullscreen",
1017
backgrounds: {
11-
default: 'light theme',
18+
default: 'default',
1219
values: [
1320
{
14-
name: 'light theme',
15-
value: '#fdfdfd',
21+
name: 'light',
22+
value: 'var(--cGray0)',
23+
},
24+
{
25+
name: 'dark',
26+
value: 'var(--cGray10)',
1627
},
1728
{
18-
name: 'dark theme',
19-
value: '#00000',
29+
name: "default",
30+
value: 'var(--cBg)',
2031
},
2132
],
2233
},
2334
}
35+
36+
37+
38+
const preview: Preview = {
39+
globalTypes: {
40+
darkMode: {
41+
// defaultValue: true, // Enable dark mode by default on all stories
42+
},
43+
},
44+
decorators: [(story, { args }) => ({
45+
directives: {extractRootEl},
46+
components: { TestWrapper, story },
47+
setup: () => ({ args }),
48+
template: `
49+
<test-wrapper :outline="args.outline"><story/></test-wrapper>
50+
`,
51+
})],
52+
args: {
53+
outline:false,
54+
}
55+
};
56+
export default preview;

README.md

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,6 @@ Custom vue component library.
1616

1717
## Usage with Vite
1818

19-
```ts
20-
css: {
21-
preprocessorOptions: {
22-
scss: {
23-
// import scss mixins into every scss file
24-
// note: requires exact (illegal) path to work
25-
// without it there are errors and i think we run into https://github.com/nuxt/vite/issues/71
26-
additionalData: `
27-
@import "node_modules/@alanscodelog/vue-components/src/assets/mixins.scss";
28-
`,
29-
},
30-
},
31-
},
32-
```
33-
3419
In `main.ts` or where vue is mounted:
3520

3621
```ts
@@ -56,6 +41,37 @@ createApp(App)
5641

5742
```
5843

44+
45+
<!-- TODO test -->
46+
You should also be able to use tailwind directly instead of importing the styles.
47+
48+
The package provides a plugin `@alanscodelog/vue-components/tailwind/plugin.js` that can be used with tailwind. It should then be configured similar to the library's config.
49+
50+
```ts
51+
import { createTailwindPlugin } from "metamorphosis/tailwind"
52+
import {libraryPlugin} from "@alanscodelog/vue-components/tailwind/plugin.js"
53+
import {themePluginOpts} from "@alanscodelog/vue-components/tailwind/themePluginOpts.js"
54+
const config = {
55+
darkMode: "class",
56+
plugins: [
57+
// integration with my theme library
58+
// alternatively provide the colors warning/ok/danger/accent (neutral is also used, but that is already provided by tailwind)
59+
createTailwindPlugin(theme, themePluginOpts),
60+
libraryPlugin,
61+
],
62+
} satisfies Config
63+
64+
export default config
65+
66+
```
67+
68+
You will need to import `@alanscodelog/vue-components/utilities.css` and optionally `@alanscodelog/vue-components/base.css` in your css file.
69+
70+
Utilities contains required utilities.
71+
72+
Base just contains some basic styles for vue's animations.
73+
74+
5975
## Getting Globally Registered Component Types
6076

6177
To get global typings, in a global declaration file (e.g. global.d.ts) do:
@@ -77,20 +93,5 @@ Everything can just be done from the config. Nuxt will automatically import the
7793
modules: [
7894
["@alanscodelog/vue-components/nuxt"],
7995
]
80-
vite: {
81-
//.. same options as above
82-
css: {
83-
preprocessorOptions: {
84-
scss: {
85-
// import scss mixins into every scss file
86-
// note: requires exact (illegal) path to work
87-
// without it there are errors and i think we run into https://github.com/nuxt/vite/issues/71
88-
additionalData: `
89-
@import "node_modules/@alanscodelog/vue-components/src/assets/mixins.scss";
90-
`,
91-
},
92-
},
93-
},
94-
}
9596

9697
```

0 commit comments

Comments
 (0)