Skip to content

Commit

Permalink
init storybook, KButton story
Browse files Browse the repository at this point in the history
  • Loading branch information
nucleogenesis committed Feb 9, 2022
1 parent a1f3964 commit 0e05acb
Show file tree
Hide file tree
Showing 5 changed files with 4,203 additions and 4,788 deletions.
27 changes: 27 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const path = require('path');
module.exports = {
"stories": [
"../stories/**/*.stories.mdx",
"../stories/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials"
],
"framework": "@storybook/vue",
"webpackFinal": async (config, { configType }) => {
// `configType` has a value of 'DEVELOPMENT' or 'PRODUCTION'
// You can change the configuration based on that.
// 'PRODUCTION' is used when building the static version of storybook.

// Make whatever fine-grained changes you need
config.module.rules.push({
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
include: path.resolve(__dirname, '../'),
});

// Return the altered config
return config;
},
}
14 changes: 14 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Vue from 'vue';
import KThemePlugin from '../lib/KThemePlugin';

KThemePlugin(Vue);

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"precompile-custom-svgs": "node utils/precompileSvgs/index.js --custom && yarn run pregenerate",
"_lint-watch-fix": "yarn lint -w -m",
"test": "jest --config=jest.conf/index.js",
"_api-watch": "chokidar \"**/lib/**\" -c \"node utils/extractApi.js\""
"_api-watch": "chokidar \"**/lib/**\" -c \"node utils/extractApi.js\"",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
},
"files": [
"lib"
Expand All @@ -35,28 +37,38 @@
},
"peerDependencies": {},
"devDependencies": {
"@babel/core": "^7.17.2",
"@material-icons/svg": "git+https://github.com/material-icons/material-icons.git",
"@mdi/svg": "^5.9.55",
"@storybook/addon-actions": "^6.4.18",
"@storybook/addon-essentials": "^6.4.18",
"@storybook/addon-links": "^6.4.18",
"@storybook/vue": "^6.4.18",
"@vuedoc/parser": "^1.4.0",
"babel-jest": "^27.4.6",
"babel-loader": "^8.2.3",
"chokidar-cli": "^2.1.0",
"consola": "^2.15.3",
"eslint-import-resolver-nuxt": "^1.0.1",
"frame-throttle": "^3.0.0",
"globby": "^6.1.0",
"jest": "^27.4.7",
"jest-serializer-vue": "^2.0.2",
"kolibri-tools": "0.15.0-dev.4",
"lockr": "^0.8.4",
"loglevel": "^1.8.0",
"material-design-icons": "^3.0.1",
"normalize.css": "^8.0.1",
"npm-run-all": "^4.1.5",
"nuxt": "2.11.0",
"prismjs": "^1.25.0",
"raw-loader": "0.5.1",
"sass": "^1.49.7",
"sass-loader": "^10.0.0",
"svg-icon-inline-loader": "^3.1.0",
"svgo": "^1.3.2",
"vue-docgen-api": "^4.41.1",
"vue-jest": "^3.0.7",
"vue-loader": "^15.9.8",
"vue-meta": "^2.4.0",
"vue-prism-component": "^1.1.1",
"vue-router": "^3.5.3",
Expand Down
95 changes: 95 additions & 0 deletions stories/KButton.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import KButton from '../lib/buttons-and-links/KButton.vue';

// More on default export: https://storybook.js.org/docs/vue/writing-stories/introduction#default-export
export default {
title: 'KButton',
component: KButton,
// More on argTypes: https://storybook.js.org/docs/vue/api/argtypes
argTypes: {
text: {
control: 'text',
defaultValue: 'Click me!',
},
icon: {
control: {
type: 'text',
defaultValue: null,
}
},
iconAfter: {
control: {
type: 'text',
defaultValue: null,
}
}
},
};

// More on component templates: https://storybook.js.org/docs/vue/writing-stories/introduction#using-args
const Template = (args, { argTypes }) => ({
props: Object.keys(argTypes),
components: { KButton },
template: '<KButton v-bind="$props">{{ text }}</KButton>',
});

export const Primary = Template.bind({});
// More on args: https://storybook.js.org/docs/vue/writing-stories/args
Primary.args = {
primary: true,
text: 'Primary Button',
};

export const Secondary = Template.bind({});
Secondary.args = {
primary: false,
text: 'Secondary Button',
};

export const PrimaryDisabled = Template.bind({});
// More on args: https://storybook.js.org/docs/vue/writing-stories/args
PrimaryDisabled.args = {
primary: true,
text: 'Primary Button',
disabled: true,
};

export const SecondaryDisabled = Template.bind({});
SecondaryDisabled.args = {
primary: false,
text: 'Secondary Button',
disabled: true,
};

export const BasicLink = Template.bind({});
BasicLink.args = {
primary: true,
appearance: 'basic-link',
text: 'Link',
};

export const FlatButtonPrimary = Template.bind({});
FlatButtonPrimary.args = {
primary: true,
appearance: 'flat-button',
text: 'Flat Primary',
};

export const FlatButtonSecondary = Template.bind({});
FlatButtonSecondary.args = {
primary: true,
appearance: 'flat-button',
text: 'Flat Secondary',
};

export const WithIconBefore = Template.bind({});
WithIconBefore.args = {
primary: true,
text: 'Add',
icon: 'add',
};
export const WithIconAfter = Template.bind({});
WithIconAfter.args = {
primary: true,
text: 'Remove',
iconAfter: 'remove',
};
Loading

0 comments on commit 0e05acb

Please sign in to comment.