Skip to content
Snippets Groups Projects
Commit 549afcde authored by Дмитрий Малюгин's avatar Дмитрий Малюгин :clock4:
Browse files

feat: completed with 9 initial components (bundle size: 248.7KB)

parent 5d51ed45
No related branches found
No related tags found
1 merge request!1Project setup and add 9 initial components
Showing
with 85 additions and 258 deletions
...@@ -281,18 +281,51 @@ const options: ISBOption[] = [ ...@@ -281,18 +281,51 @@ const options: ISBOption[] = [
const visible = ref(false); const visible = ref(false);
const onClose = () => console.log('close!'); const onClose = () => console.log('close!');
const value = ref(); const value = ref();
const active = ref(false);
const sliderValue = ref(1);
</script> </script>
<template> <template>
{{ value }}
<Modal v-model:visible="visible" theme="red" @onClose="onClose" <Modal v-model:visible="visible" theme="red" @onClose="onClose"
><template #header>huuuuuuuuuuui</template>Lorem ipsum dolor sit amet, consectetur adipisicing ><template #header>huuuuuuuuuuui</template>Lorem ipsum dolor sit amet, consectetur adipisicing
elit. Eaque explicabo, facere fuga hic id impedit magnam maiores minima necessitatibus, nemo elit. Eaque explicabo, facere fuga hic id impedit magnam maiores minima necessitatibus, nemo
nesciunt nihil officia, pariatu nemo nesciunt nihil officia, pariatur praesentium quas quisquam nesciunt nihil officia, pariatu nemo nesciunt nihil officia, pariatur praesentium quas quisquam
repellat saepe temporibus?</Modal repellat saepe temporibus? Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eaque
explicabo, facere fuga hic id impedit magnam maiores minima necessitatibus, nemo nesciunt nihil
officia, pariatu nemo nesciunt nihil officia, pariatur praesentium quas quisquam repellat saepe
temporibus?</Modal
> >
<MenuDial :items="[{ label: 'First' }]" /> <MenuDial
v-model:active="active"
theme="sky"
direction="right"
:items="[
{
label: 'font-family',
theme: 'green',
link: 'https://developer.mozilla.org/en-US/docs/Web/CSS/font-family',
linkBlank: true,
textStyle: 'bold',
},
{
label: 'Second',
theme: 'red',
textStyle: 'italic',
},
]"
>
<template #1IconBefore>
<AnchorLinkIcon size="20" color="white" />
</template>
<template #2IconBefore>
<CrossIcon color="white" />
</template>
<template #2IconAfter>
<CrossIcon color="white" />
</template>
</MenuDial>
<Slider <Slider
v-model:value="sliderValue"
:options="sliderOptions" :options="sliderOptions"
orientation="vertical" orientation="vertical"
width="400" width="400"
...@@ -330,7 +363,10 @@ const value = ref(); ...@@ -330,7 +363,10 @@ const value = ref();
recusandae voluptatibus! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque recusandae voluptatibus! Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque
blanditiis consectetur cum delectus ducimus eius est hic incidunt iusto molestiae odio optio blanditiis consectetur cum delectus ducimus eius est hic incidunt iusto molestiae odio optio
reiciendis reprehenderit saepe tempora vel, veniam veritatis voluptates. Lorem ipsum dolor sit reiciendis reprehenderit saepe tempora vel, veniam veritatis voluptates. Lorem ipsum dolor sit
amet, consectetur adipisicing elit. amet, consectetur adipisicing elit. Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Eaque explicabo, facere fuga hic id impedit magnam maiores minima necessitatibus, nemo
nesciunt nihil officia, pariatu nemo nesciunt nihil officia, pariatur praesentium quas
quisquam repellat saepe temporibus?
</p> </p>
<template #footer> <template #footer>
pizdwertyukilokl,kmjhgfw ewesrdtyukilo,kmjng eartyukikdhgfgjhklj.,kga</template pizdwertyukilokl,kmjhgfw ewesrdtyukilo,kmjng eartyukikdhgfgjhklj.,kga</template
......
...@@ -11,3 +11,7 @@ ...@@ -11,3 +11,7 @@
width: 8px; width: 8px;
height: 8px; height: 8px;
} }
::-webkit-scrollbar-thumb {
border-radius: 5px;
background-color: #888;
}
...@@ -23,6 +23,8 @@ export type TSize = 'small' | 'medium' | 'large' | 'huge'; ...@@ -23,6 +23,8 @@ export type TSize = 'small' | 'medium' | 'large' | 'huge';
export type TTextStyle = 'bold' | 'italic'; export type TTextStyle = 'bold' | 'italic';
export type TDirection = 'up' | 'right' | 'down' | 'left';
export type TPosition = 'top' | 'right' | 'bottom' | 'left'; export type TPosition = 'top' | 'right' | 'bottom' | 'left';
export type TExpandedPosition = TPosition | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight'; export type TExpandedPosition = TPosition | 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
......
import type { import type {
TBorder, TBorder,
TDirection,
TExpandedPosition, TExpandedPosition,
TIcons, TIcons,
TPosition, TPosition,
...@@ -32,11 +33,14 @@ export interface IMDProps { ...@@ -32,11 +33,14 @@ export interface IMDProps {
label: string; label: string;
theme?: string; theme?: string;
textStyle?: TTextStyle; textStyle?: TTextStyle;
link?: string;
linkBlank?: boolean;
onClick?: () => void; onClick?: () => void;
}[]; }[];
size?: TSize; size?: TSize;
theme?: string; theme?: string;
direction?: TPosition; direction?: TDirection;
// direction?: TDirection | 'circle';
} }
export interface ISliderProps { export interface ISliderProps {
......
...@@ -80,10 +80,7 @@ const meta: Meta = { ...@@ -80,10 +80,7 @@ const meta: Meta = {
], ],
}, },
}, },
args: { args: {},
// primary: false,
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
},
} satisfies Meta<typeof Button>; } satisfies Meta<typeof Button>;
export default meta; export default meta;
......
...@@ -37,11 +37,7 @@ const meta: Meta = { ...@@ -37,11 +37,7 @@ const meta: Meta = {
], ],
}, },
}, },
args: { args: {},
// primary: false,
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
// onClick: fn(),
},
} satisfies Meta<typeof Divider>; } satisfies Meta<typeof Divider>;
export default meta; export default meta;
......
...@@ -2,7 +2,6 @@ import type { Meta, StoryObj } from '@storybook/vue3'; ...@@ -2,7 +2,6 @@ import type { Meta, StoryObj } from '@storybook/vue3';
import Drawer from './Drawer.vue'; import Drawer from './Drawer.vue';
import { iconsSet } from '@/common/constants/icons'; import { iconsSet } from '@/common/constants/icons';
import { fn } from '@storybook/test';
const meta: Meta = { const meta: Meta = {
title: 'Components/Drawer', title: 'Components/Drawer',
...@@ -48,11 +47,7 @@ const meta: Meta = { ...@@ -48,11 +47,7 @@ const meta: Meta = {
], ],
}, },
}, },
args: { args: {},
// primary: false,
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
onClose: fn(),
},
} satisfies Meta<typeof Drawer>; } satisfies Meta<typeof Drawer>;
export default meta; export default meta;
......
...@@ -46,7 +46,7 @@ const drawerWidth = computed(() => { ...@@ -46,7 +46,7 @@ const drawerWidth = computed(() => {
drawerBackgroundOpened: visible, drawerBackgroundOpened: visible,
}, },
]" ]"
@click.prevent="dismissible ? (visible = false) : false" @click.prevent="dismissible ? (visible = false) : ''"
></section> ></section>
<section <section
:style="`color: ${textColor}; background-color: ${themeColor}`" :style="`color: ${textColor}; background-color: ${themeColor}`"
...@@ -150,6 +150,7 @@ const drawerWidth = computed(() => { ...@@ -150,6 +150,7 @@ const drawerWidth = computed(() => {
flex: 1 1 auto; flex: 1 1 auto;
overflow: auto; overflow: auto;
margin: 10px; margin: 10px;
padding-right: 10px;
} }
.drawerFooter { .drawerFooter {
padding: 10px 10px 0 10px; padding: 10px 10px 0 10px;
......
...@@ -57,10 +57,7 @@ const meta: Meta = { ...@@ -57,10 +57,7 @@ const meta: Meta = {
], ],
}, },
}, },
args: { args: {},
// primary: false,
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
},
} satisfies Meta<typeof Modal>; } satisfies Meta<typeof Modal>;
export default meta; export default meta;
......
...@@ -85,8 +85,8 @@ document.addEventListener('keydown', onKeydown); ...@@ -85,8 +85,8 @@ document.addEventListener('keydown', onKeydown);
position: fixed; position: fixed;
top: -100%; top: -100%;
left: -100%; left: -100%;
width: 250vw; width: 200vw;
height: 250vh; height: 200vh;
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
z-index: -50; z-index: -50;
opacity: 0; opacity: 0;
......
import type { Meta, StoryObj } from '@storybook/vue3'; import type { Meta, StoryObj } from '@storybook/vue3';
import SelectButton from './SelectButton.vue'; import SelectButton from './SelectButton.vue';
import { fn } from '@storybook/test';
const meta: Meta = { const meta: Meta = {
title: 'Components/SelectButton', title: 'Components/SelectButton',
...@@ -16,7 +15,7 @@ const meta: Meta = { ...@@ -16,7 +15,7 @@ const meta: Meta = {
}, },
argTypes: { argTypes: {
options: { options: {
control: 'array', control: 'object',
}, },
size: { control: 'select', options: ['small', 'medium', 'large', 'huge'] }, size: { control: 'select', options: ['small', 'medium', 'large', 'huge'] },
rounded: { control: 'boolean' }, rounded: { control: 'boolean' },
...@@ -62,11 +61,7 @@ const meta: Meta = { ...@@ -62,11 +61,7 @@ const meta: Meta = {
}, },
disabled: { control: 'boolean' }, disabled: { control: 'boolean' },
}, },
args: { args: {},
// primary: false,
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
onClick: fn(),
},
} satisfies Meta<typeof SelectButton>; } satisfies Meta<typeof SelectButton>;
export default meta; export default meta;
......
...@@ -63,10 +63,7 @@ const meta: Meta = { ...@@ -63,10 +63,7 @@ const meta: Meta = {
], ],
}, },
}, },
args: { args: {},
// primary: false,
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
},
} satisfies Meta<typeof Slider>; } satisfies Meta<typeof Slider>;
export default meta; export default meta;
......
...@@ -59,10 +59,7 @@ const meta: Meta = { ...@@ -59,10 +59,7 @@ const meta: Meta = {
darkNegative: { control: 'boolean' }, darkNegative: { control: 'boolean' },
disabled: { control: 'boolean' }, disabled: { control: 'boolean' },
}, },
args: { args: {},
// primary: false,
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
},
} satisfies Meta<typeof ToggleSwitch>; } satisfies Meta<typeof ToggleSwitch>;
export default meta; export default meta;
......
...@@ -77,7 +77,7 @@ const sizes = computed(() => { ...@@ -77,7 +77,7 @@ const sizes = computed(() => {
<span <span
:style="`background-color: ${disabled ? '#e1e7f1 !important' : themeColor}; border-radius: ${sizes.borderRadius}px;`" :style="`background-color: ${disabled ? '#e1e7f1 !important' : themeColor}; border-radius: ${sizes.borderRadius}px;`"
:class="[ :class="[
'activeBackground', 'background',
{ {
inactiveBackground: !active && !disabled, inactiveBackground: !active && !disabled,
}, },
...@@ -94,20 +94,20 @@ const sizes = computed(() => { ...@@ -94,20 +94,20 @@ const sizes = computed(() => {
.switcher { .switcher {
position: relative; position: relative;
} }
.activeBackground { .background {
display: block; display: block;
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
transition: background-color 0.2s ease-in-out; transition: all 0.2s ease-in-out;
} }
.inactiveBackground { .inactiveBackground {
background-color: v-bind(inactiveColor) !important; background-color: v-bind(inactiveColor) !important;
transition: background-color 0.2s ease-in-out; transition: all 0.2s ease-in-out;
} }
.switcher:hover .inactiveBackground { .switcher:hover .background {
filter: brightness(90%); filter: brightness(90%);
} }
.switcherCircle { .switcherCircle {
......
...@@ -48,13 +48,6 @@ const emit = defineEmits(['toggleIsOpen', 'onClick']); ...@@ -48,13 +48,6 @@ const emit = defineEmits(['toggleIsOpen', 'onClick']);
" "
size="17" size="17"
/> />
<component
:is="iconsSet[item.iconBefore]"
v-if="item.iconBefore"
:color="convert500ThemeToColor(item.iconColor)"
style="min-width: 17px"
size="17"
/>
<a <a
:href="item.link" :href="item.link"
:target="item.linkBlank ? '_blank' : '_self'" :target="item.linkBlank ? '_blank' : '_self'"
...@@ -76,15 +69,20 @@ const emit = defineEmits(['toggleIsOpen', 'onClick']); ...@@ -76,15 +69,20 @@ const emit = defineEmits(['toggleIsOpen', 'onClick']);
emit('onClick', item.link); emit('onClick', item.link);
} }
" "
>{{ item.label }}</a ><component
> :is="iconsSet[item.iconBefore]"
<component v-if="item.iconBefore"
:is="iconsSet[item.iconAfter]" :color="convert500ThemeToColor(item.iconColor)"
v-if="item.iconAfter" style="min-width: 17px"
:color="convert500ThemeToColor(item.iconColor)" size="17" />
style="min-width: 17px" <span>{{ item.label }}</span
size="17" ><component
/> :is="iconsSet[item.iconAfter]"
v-if="item.iconAfter"
:color="convert500ThemeToColor(item.iconColor)"
style="min-width: 17px"
size="17"
/></a>
</section> </section>
<section class="children"> <section class="children">
<TreeItems <TreeItems
...@@ -107,7 +105,8 @@ const emit = defineEmits(['toggleIsOpen', 'onClick']); ...@@ -107,7 +105,8 @@ const emit = defineEmits(['toggleIsOpen', 'onClick']);
background-color: v-bind(themeColor); background-color: v-bind(themeColor);
} }
.label { .label {
display: inline-block; display: flex;
gap: 5px;
position: relative; position: relative;
padding: 4px 5px; padding: 4px 5px;
background-color: v-bind(themeColor); background-color: v-bind(themeColor);
......
...@@ -39,10 +39,7 @@ const meta: Meta = { ...@@ -39,10 +39,7 @@ const meta: Meta = {
], ],
}, },
}, },
args: { args: {},
// primary: false,
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
},
} satisfies Meta<typeof TreeList>; } satisfies Meta<typeof TreeList>;
export default meta; export default meta;
......
import { fn } from '@storybook/test';
import type { Meta, StoryObj } from '@storybook/vue3';
import Button from './ButtonStorybook.vue';
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
const meta: Meta = {
title: 'Examples/Button',
component: Button,
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
argTypes: {
size: { control: 'select', options: ['small', 'medium', 'large'] },
backgroundColor: { control: 'color' },
},
args: {
primary: false,
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
onClick: fn(),
},
} satisfies Meta<typeof Button>;
export default meta;
type Story = StoryObj<typeof meta>;
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/api/csf
* to learn how to use render functions.
*/
export const Primary: Story = {
args: {
primary: true,
label: 'Button',
},
};
export const Secondary: Story = {
args: {
primary: false,
label: 'Button',
},
};
export const Large: Story = {
args: {
label: 'Button',
size: 'large',
},
};
export const Small: Story = {
args: {
label: 'Button',
size: 'small',
},
};
export const DefaultButton: Story = {
args: {
primary: false,
label: 'Button',
},
};
<template>
<button type="button" :class="classes" @click="onClick" :style="style">{{ label }}</button>
</template>
<script lang="ts" setup>
import './buttonStorybook.css';
import { computed } from 'vue';
const props = withDefaults(
defineProps<{
/**
* The label of the button
*/
label: string;
/**
* primary or secondary button
*/
primary?: boolean;
/**
* size of the button
*/
size?: 'small' | 'medium' | 'large';
/**
* background color of the button
*/
backgroundColor?: string;
}>(),
{ primary: false },
);
const emit = defineEmits<{
(e: 'click', id: number): void;
}>();
const classes = computed(() => ({
'storybook-button': true,
'storybook-button--primary': props.primary,
'storybook-button--secondary': !props.primary,
[`storybook-button--${props.size || 'medium'}`]: true,
}));
const style = computed(() => ({
backgroundColor: props.backgroundColor,
}));
const onClick = () => {
emit('click', 1);
};
</script>
.storybook-button {
display: inline-block;
cursor: pointer;
border: 0;
border-radius: 3em;
font-weight: 700;
line-height: 1;
font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.storybook-button--primary {
background-color: #1ea7fd;
color: white;
}
.storybook-button--secondary {
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
background-color: transparent;
color: #333;
}
.storybook-button--small {
padding: 10px 16px;
font-size: 12px;
}
.storybook-button--medium {
padding: 11px 20px;
font-size: 14px;
}
.storybook-button--large {
padding: 12px 24px;
font-size: 16px;
}
import { fn } from '@storybook/test';
import type { Meta, StoryObj } from '@storybook/vue3';
import MyHeader from './Header.vue';
const meta: Meta = {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/configure/#configure-story-loading
* to learn how to generate automatic titles
*/
title: 'Examples/Header',
component: MyHeader,
render: (args: unknown) => ({
components: { MyHeader },
setup() {
return { args };
},
template: '<my-header :user="args.user" />',
}),
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
layout: 'fullscreen',
},
args: {
onLogin: fn(),
onLogout: fn(),
onCreateAccount: fn(),
},
// This component will have an automatically generated docsPage entry: https://storybook.js.org/docs/writing-docs/autodocs
tags: ['autodocs'],
} satisfies Meta<typeof MyHeader>;
export default meta;
type Story = StoryObj<typeof meta>;
export const LoggedIn: Story = {
args: {
user: {
name: 'Jane Doe',
},
},
};
export const LoggedOut: Story = {
args: {
user: null,
},
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment