Skip to content

Commit 0920ba0

Browse files
committed
Implement design system button
1 parent 9bb1bac commit 0920ba0

17 files changed

Lines changed: 19735 additions & 17772 deletions

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
node_modules
22
dist
3-
lib
43
src/versionInfo.ts
54
.idea
65
.vscode

.storybook/main.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1+
import Icons from 'unplugin-icons/webpack'
2+
import iconsConfig from '../config/icons'
3+
import postCSSConfig from '../config/postcss'
4+
15
export default {
26
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
37

8+
swc: (config) => ({
9+
...config,
10+
jsc: {
11+
...config.jsc,
12+
parser: {
13+
...config.jsc?.parser,
14+
decorators: true,
15+
},
16+
transform: {
17+
...config.jsc?.transform,
18+
legacyDecorator: true,
19+
useDefineForClassFields: false,
20+
},
21+
},
22+
}),
23+
424
addons: [
525
'@storybook/addon-links',
626
'@storybook/addon-essentials',
@@ -37,6 +57,32 @@ export default {
3757
$rdf: 'rdflib'
3858
}
3959

60+
// Configure icons
61+
config.plugins.push(Icons(iconsConfig))
62+
63+
// Configure component styles
64+
const litCssPattern = /\.styles\.css$/
65+
66+
config.module.rules = config.module.rules.map(rule => {
67+
if (rule?.test?.test?.('component.css')) {
68+
return {
69+
...rule,
70+
exclude: [
71+
...(Array.isArray(rule.exclude) ? rule.exclude : rule.exclude ? [rule.exclude] : []),
72+
litCssPattern
73+
]
74+
}
75+
}
76+
77+
return rule
78+
})
79+
80+
config.module.rules.push({
81+
test: litCssPattern,
82+
loader: 'lit-css-loader',
83+
options: postCSSConfig
84+
})
85+
4086
return config
4187
}
4288
}

.storybook/preview.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '../src/design-system/styles/variables.css'
2+
13
// For backward compatibility, provide rdflib and solid-logic as globals
24
import * as rdflib from 'rdflib'
35
import * as solidLogic from 'solid-logic'

babel.config.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ export default {
55
browsers: ['> 1%', 'last 3 versions', 'not dead']
66
}
77
}],
8-
['@babel/preset-typescript', { allowDeclareFields: true }],
8+
[
9+
'@babel/preset-typescript', {
10+
allowDeclareFields: true,
11+
useDefineForClassFields: false,
12+
}
13+
],
914
],
1015
plugins: [
1116
'@babel/plugin-transform-runtime'

config/icons.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const compiler = {
2+
compiler (svg, collection, icon) {
3+
const id = `icon-${collection}-${icon}`
4+
const className = id.replace(/-/g, '')
5+
6+
return `
7+
export default class ${className} extends HTMLElement {
8+
constructor() {
9+
super()
10+
this.attachShadow({ mode: 'open' }).innerHTML = ${JSON.stringify('<style>:host { display: inline-flex; }</style>' + svg)}
11+
}
12+
}
13+
14+
customElements.define('${id}', ${className})
15+
`
16+
},
17+
}
18+
19+
/** @type {import('unplugin-icons').Options} */
20+
export default {
21+
scale: 1,
22+
compiler,
23+
iconCustomizer (_, __, props) {
24+
props.width = '100%'
25+
props.height = '100%'
26+
}
27+
}

config/postcss.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import PostCSS from 'postcss'
2+
import TailwindCSS from '@tailwindcss/postcss'
3+
4+
const cssProcessor = PostCSS([TailwindCSS()])
5+
6+
export default {
7+
async transform (css, { filePath }) {
8+
const result = await cssProcessor.process(css, { from: filePath })
9+
10+
return result.css
11+
}
12+
}

0 commit comments

Comments
 (0)