chore: add histoire support (#510)

Signed-off-by: Ryan Wang <i@ryanc.cc>
pull/511/head
Ryan Wang 2022-03-16 21:26:21 +08:00 committed by GitHub
parent 0b1e087c43
commit 0b1acce556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 619 additions and 49 deletions

View File

@ -13,6 +13,9 @@ module.exports = {
node: true,
"vue/setup-compiler-macros": true,
},
rules: {
"vue/multi-word-component-names": 0,
},
overrides: [
{
files: ["cypress/integration/**.spec.{js,ts,jsx,tsx}"],

1
.gitignore vendored
View File

@ -11,6 +11,7 @@ node_modules
.DS_Store
dist
dist-ssr
histoire-dist
coverage
*.local

3
histoire.config.ts Normal file
View File

@ -0,0 +1,3 @@
import { defineConfig } from "histoire";
export default defineConfig({});

View File

@ -10,7 +10,9 @@
"test:e2e": "start-server-and-test preview http://127.0.0.1:5050/ 'cypress open'",
"test:e2e:ci": "start-server-and-test preview http://127.0.0.1:5050/ 'cypress run'",
"typecheck": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"story:dev": "histoire dev",
"story:build": "histoire build"
},
"dependencies": {
"pinia": "^2.0.11",
@ -32,10 +34,12 @@
"eslint": "^8.10.0",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-vue": "^8.5.0",
"histoire": "^0.1.1",
"husky": "^7.0.4",
"jsdom": "^19.0.0",
"postcss": "^8.4.8",
"prettier": "^2.5.1",
"sass": "^1.49.9",
"start-server-and-test": "^1.14.0",
"tailwindcss": "^3.0.23",
"typescript": "~4.5.5",

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
<template>
<Story title="Button">
<Variant :init-state="initState" title="playground">
<template #default="{ state }">
<VButton :type="state.type"> Hello world </VButton>
</template>
</Variant>
<Variant icon="carbon:star-filled" icon-color="#10B981" title="secondary">
<VButton type="secondary"> Hello world </VButton>
</Variant>
</Story>
</template>
<script setup>
import { VButton } from "./index";
function initState() {
return {
type: "primary",
};
}
</script>

View File

@ -0,0 +1,30 @@
<template>
<button :class="[`btn-${size}`, `btn-${type}`]">
<slot />
</button>
</template>
<script lang="ts" setup>
import type { PropType } from "vue";
import type { Size, Type } from "@/components/base/button/interface";
defineProps({
type: {
type: String as PropType<Type>,
default: "default",
},
size: {
type: String as PropType<Size>,
default: "md",
},
loading: {
type: Boolean,
default: false,
},
});
</script>
<style>
.btn-secondary {
@apply bg-black;
@apply text-white;
}
</style>

View File

@ -0,0 +1 @@
export { default as VButton } from "./Button.vue";

View File

@ -0,0 +1,2 @@
export type Type = "default" | "primary" | "secondary" | "error";
export type Size = "lg" | "md" | "sm" | "xs";