-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a989f7
commit 1dfcca7
Showing
437 changed files
with
11,321 additions
and
1,180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# (cd .; pnpm tsc --jsx react --jsxFactory h ./generate.tsx && node ./generate.js) | ||
/generate.js | ||
# (cd .; pnpm tsc ./preload-theme.ts && node ./preload-theme.js) | ||
/preload-theme.js | ||
/theme.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import * as fs from 'node:fs/promises'; | ||
import { basename, dirname, join } from 'node:path/posix'; | ||
import { promisify } from 'node:util'; | ||
import { generate } from 'astring'; | ||
import type * as estree from 'estree'; | ||
import * as glob from 'glob'; | ||
import { format } from 'prettier'; | ||
|
||
function h<T extends estree.Node>(component: T['type'], props: Omit<T, 'type'>): T { | ||
const type = component.replace(/(?:^|-)([a-z])/g, (_, c) => c.toUpperCase()); | ||
return Object.assign(props, { type }) as T; | ||
} | ||
|
||
function toStories(component: string, location: string): string { | ||
const literal = ( | ||
<literal value={join(location, component).slice(4, -4)} /> | ||
) as unknown as estree.Literal; | ||
const identifier = ( | ||
<identifier name={component.slice(0, -4).replace(/[-.]|^(?=\d)/g, '_')} /> | ||
) as unknown as estree.Identifier; | ||
const program = ( | ||
<program | ||
body={[ | ||
<import-declaration | ||
source={<literal value="@storybook/vue3" />} | ||
specifiers={[ | ||
<import-specifier | ||
local={<identifier name="Meta" />} | ||
imported={<identifier name="Meta" />} | ||
/>, | ||
<import-specifier | ||
local={<identifier name="Story" />} | ||
imported={<identifier name="Story" />} | ||
/>, | ||
]} | ||
/>, | ||
<import-declaration | ||
source={<literal value={`./${component}`} />} | ||
specifiers={[ | ||
<import-default-specifier | ||
local={identifier} | ||
imported={identifier} | ||
/>, | ||
]} | ||
/>, | ||
<variable-declaration | ||
kind="const" | ||
declarations={[ | ||
<variable-declarator | ||
id={<identifier name="meta" />} | ||
init={ | ||
<object-expression | ||
properties={[ | ||
<property | ||
key={<identifier name="title" />} | ||
value={literal} | ||
kind="init" | ||
/>, | ||
<property | ||
key={<identifier name="component" />} | ||
value={identifier} | ||
kind="init" | ||
/>, | ||
]} | ||
/> | ||
} | ||
/>, | ||
]} | ||
/>, | ||
<export-named-declaration | ||
declaration={ | ||
<variable-declaration | ||
kind="const" | ||
declarations={[ | ||
<variable-declarator | ||
id={<identifier name="Default" />} | ||
init={ | ||
<object-expression | ||
properties={[ | ||
<property | ||
key={<identifier name="components" />} | ||
value={ | ||
<object-expression | ||
properties={[ | ||
<property | ||
key={identifier} | ||
value={identifier} | ||
kind="init" | ||
shorthand | ||
/>, | ||
]} | ||
/> | ||
} | ||
kind="init" | ||
/>, | ||
<property | ||
key={<identifier name="template" />} | ||
value={<literal value={`<${component.slice(0, -4)} />`} />} | ||
kind="init" | ||
/>, | ||
]} | ||
/> | ||
} | ||
/>, | ||
]} | ||
/> | ||
} | ||
/>, | ||
<export-default-declaration | ||
declaration={<identifier name="meta" />} | ||
/>, | ||
]} | ||
/> | ||
) as unknown as estree.Program; | ||
return format( | ||
generate(program), | ||
{ | ||
parser: 'babel-ts', | ||
singleQuote: true, | ||
useTabs: true, | ||
} | ||
); | ||
} | ||
|
||
promisify(glob)('src/{components,pages,ui,widgets}/**/*.vue').then((components) => Promise.all( | ||
components.map((component) => { | ||
const stories = component.replace(/\.vue$/, '.stories.ts'); | ||
fs.stat(stories).then( | ||
() => {}, | ||
() => { | ||
fs.writeFile(stories, toStories(basename(component), dirname(component))); | ||
} | ||
); | ||
}) | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { StorybookConfig } from '@storybook/vue3-vite'; | ||
const config: StorybookConfig = { | ||
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], | ||
addons: [ | ||
'@storybook/addon-links', | ||
'@storybook/addon-essentials', | ||
'@storybook/addon-interactions', | ||
], | ||
framework: { | ||
name: '@storybook/vue3-vite', | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: 'tag', | ||
}, | ||
}; | ||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { readFile, writeFile } from 'node:fs/promises'; | ||
import { resolve } from 'node:path'; | ||
import * as JSON5 from 'json5'; | ||
|
||
Promise.all([ | ||
readFile(resolve(__dirname, '../src/themes/_light.json5'), 'utf8'), | ||
readFile(resolve(__dirname, '../src/themes/l-light.json5'), 'utf8'), | ||
]).then((sources) => { | ||
const base = JSON5.parse(sources[0]); | ||
const theme = JSON5.parse(sources[1]); | ||
writeFile( | ||
resolve(__dirname, './theme.ts'), | ||
`export default ${JSON.stringify( | ||
Object.assign(theme, { | ||
base: undefined, | ||
props: Object.assign(base.props, theme.props), | ||
}), | ||
undefined, | ||
2, | ||
)} as const;`, | ||
'utf8' | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<script> | ||
window.global = window; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { Preview } from '@storybook/vue3'; | ||
import { applyTheme } from '../src/scripts/theme'; | ||
import theme from './theme'; | ||
import '../src/style.scss'; | ||
|
||
applyTheme(theme); | ||
|
||
const preview = { | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
} satisfies Preview; | ||
|
||
export default preview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkAbuseReport from './MkAbuseReport.vue'; | ||
const meta = { | ||
title: 'components/MkAbuseReport', | ||
component: MkAbuseReport, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkAbuseReport, | ||
}, | ||
template: '<MkAbuseReport />', | ||
}; | ||
export default meta; |
13 changes: 13 additions & 0 deletions
13
packages/frontend/src/components/MkAbuseReportWindow.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkAbuseReportWindow from './MkAbuseReportWindow.vue'; | ||
const meta = { | ||
title: 'components/MkAbuseReportWindow', | ||
component: MkAbuseReportWindow, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkAbuseReportWindow, | ||
}, | ||
template: '<MkAbuseReportWindow />', | ||
}; | ||
export default meta; |
13 changes: 13 additions & 0 deletions
13
packages/frontend/src/components/MkAchievements.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkAchievements from './MkAchievements.vue'; | ||
const meta = { | ||
title: 'components/MkAchievements', | ||
component: MkAchievements, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkAchievements, | ||
}, | ||
template: '<MkAchievements />', | ||
}; | ||
export default meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkAnalogClock from './MkAnalogClock.vue'; | ||
const meta = { | ||
title: 'components/MkAnalogClock', | ||
component: MkAnalogClock, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkAnalogClock, | ||
}, | ||
template: '<MkAnalogClock />', | ||
}; | ||
export default meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkAsUi from './MkAsUi.vue'; | ||
const meta = { | ||
title: 'components/MkAsUi', | ||
component: MkAsUi, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkAsUi, | ||
}, | ||
template: '<MkAsUi />', | ||
}; | ||
export default meta; |
13 changes: 13 additions & 0 deletions
13
packages/frontend/src/components/MkAutocomplete.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkAutocomplete from './MkAutocomplete.vue'; | ||
const meta = { | ||
title: 'components/MkAutocomplete', | ||
component: MkAutocomplete, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkAutocomplete, | ||
}, | ||
template: '<MkAutocomplete />', | ||
}; | ||
export default meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkAvatars from './MkAvatars.vue'; | ||
const meta = { | ||
title: 'components/MkAvatars', | ||
component: MkAvatars, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkAvatars, | ||
}, | ||
template: '<MkAvatars />', | ||
}; | ||
export default meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkButton from './MkButton.vue'; | ||
const meta = { | ||
title: 'components/MkButton', | ||
component: MkButton, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkButton, | ||
}, | ||
template: '<MkButton />', | ||
}; | ||
export default meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkCaptcha from './MkCaptcha.vue'; | ||
const meta = { | ||
title: 'components/MkCaptcha', | ||
component: MkCaptcha, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkCaptcha, | ||
}, | ||
template: '<MkCaptcha />', | ||
}; | ||
export default meta; |
13 changes: 13 additions & 0 deletions
13
packages/frontend/src/components/MkChannelFollowButton.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkChannelFollowButton from './MkChannelFollowButton.vue'; | ||
const meta = { | ||
title: 'components/MkChannelFollowButton', | ||
component: MkChannelFollowButton, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkChannelFollowButton, | ||
}, | ||
template: '<MkChannelFollowButton />', | ||
}; | ||
export default meta; |
13 changes: 13 additions & 0 deletions
13
packages/frontend/src/components/MkChannelPreview.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Meta, Story } from '@storybook/vue3'; | ||
import MkChannelPreview from './MkChannelPreview.vue'; | ||
const meta = { | ||
title: 'components/MkChannelPreview', | ||
component: MkChannelPreview, | ||
}; | ||
export const Default = { | ||
components: { | ||
MkChannelPreview, | ||
}, | ||
template: '<MkChannelPreview />', | ||
}; | ||
export default meta; |
Oops, something went wrong.