-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(VsProgress) add vs-progress component
- Loading branch information
Showing
9 changed files
with
223 additions
and
1 deletion.
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
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
23 changes: 23 additions & 0 deletions
23
packages/vlossom/src/components/vs-progress/VsProgress.scss
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 @@ | ||
progress { | ||
-webkit-appearance: none; | ||
appearance: none; | ||
width: var(--vs-progress-width, 100%); | ||
height: var(--vs-progress-height, 0.7rem); | ||
} | ||
|
||
progress[value] { | ||
&::-webkit-progress-bar { | ||
overflow: hidden; | ||
background-color: var(--vs-light-backgroundColor); | ||
border-radius: var(--vs-progress-borderRadius, 0.4rem); | ||
} | ||
|
||
&::-webkit-progress-value { | ||
position: relative; | ||
background-color: var(--vs-progress-backgroundColor, var(--vs-comp-backgroundColor)); | ||
} | ||
|
||
&.primary::-webkit-progress-value { | ||
background-color: var(--vs-progress-backgroundColor, var(--vs-comp-backgroundColor-primary)); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
packages/vlossom/src/components/vs-progress/VsProgress.vue
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,54 @@ | ||
<template> | ||
<progress | ||
:value="value" | ||
:max="max" | ||
:class="['vs-progress', `vs-${computedColorScheme}`, { ...classObj }]" | ||
:style="customProperties" | ||
/> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { PropType, defineComponent, toRefs, computed } from 'vue'; | ||
import { useColorScheme, useCustomStyle } from '@/composables'; | ||
import { ColorScheme, VsComponent } from '@/declaration/types'; | ||
interface ProgressStyleSet { | ||
borderRadius: string; | ||
height: string; | ||
width: string; | ||
} | ||
export type VsProgressStyleSet = Partial<ProgressStyleSet>; | ||
const name = VsComponent.VsProgress; | ||
export default defineComponent({ | ||
name: name, | ||
props: { | ||
colorScheme: { type: String as PropType<ColorScheme> }, | ||
styleSet: { type: [String, Object] as PropType<string | VsProgressStyleSet>, default: '' }, | ||
max: { type: Number, default: 100 }, | ||
value: { type: Number, default: 0 }, | ||
primary: { type: Boolean, default: false }, | ||
}, | ||
setup(props) { | ||
const { colorScheme, styleSet, primary } = toRefs(props); | ||
const { computedColorScheme } = useColorScheme(name, colorScheme); | ||
const { customProperties } = useCustomStyle<VsProgressStyleSet>(name, styleSet); | ||
const classObj = computed(() => ({ | ||
primary: primary.value, | ||
})); | ||
return { | ||
computedColorScheme, | ||
customProperties, | ||
classObj, | ||
}; | ||
}, | ||
}); | ||
</script> | ||
|
||
<style src="./VsProgress.scss" scoped /> |
31 changes: 31 additions & 0 deletions
31
packages/vlossom/src/components/vs-progress/__tests__/vs-progress.test.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,31 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { mount } from '@vue/test-utils'; | ||
import VsProgress from './../VsProgress.vue'; | ||
|
||
describe('VsProgress', () => { | ||
it('value 를 지정할 수 있다', () => { | ||
// given | ||
const wrapper = mount(VsProgress, { | ||
props: { | ||
value: 50, | ||
}, | ||
}); | ||
|
||
// then | ||
expect(wrapper.props('value')).toBe(50); | ||
expect(wrapper.find('.vs-progress').element.getAttribute('value')).toBe('50'); | ||
}); | ||
|
||
it('max 를 지정할 수 있다', () => { | ||
// given | ||
const wrapper = mount(VsProgress, { | ||
props: { | ||
max: 200, | ||
}, | ||
}); | ||
|
||
// then | ||
expect(wrapper.props('max')).toBe(200); | ||
expect(wrapper.find('.vs-progress').element.getAttribute('max')).toBe('200'); | ||
}); | ||
}); |
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,12 @@ | ||
import { VsComponent } from '@/declaration/types'; | ||
import VsProgress from './VsProgress.vue'; | ||
import type { VsProgressStyleSet } from './VsProgress.vue'; | ||
|
||
type VsProgressInstance = InstanceType<typeof VsProgress>; | ||
|
||
export type { VsProgressInstance, VsProgressStyleSet }; | ||
|
||
export default { | ||
name: VsComponent.VsProgress, | ||
component: VsProgress, | ||
}; |
78 changes: 78 additions & 0 deletions
78
packages/vlossom/src/components/vs-progress/stories/VsProgress.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,78 @@ | ||
import type { Meta, StoryObj } from '@storybook/vue3'; | ||
import { colorScheme } from '@/storybook/args'; | ||
import VsProgress from './../VsProgress.vue'; | ||
|
||
const meta: Meta<typeof VsProgress> = { | ||
title: 'Components/Base Components/VsProgress', | ||
component: VsProgress, | ||
render: (args: any) => ({ | ||
components: { VsProgress }, | ||
setup() { | ||
return { args }; | ||
}, | ||
template: '<vs-progress v-bind="args" />', | ||
}), | ||
tags: ['autodocs'], | ||
argTypes: { | ||
colorScheme, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof VsProgress>; | ||
|
||
export const Default: Story = {}; | ||
|
||
export const ColorScheme: Story = { | ||
render: (args: any) => ({ | ||
components: { VsProgress }, | ||
setup() { | ||
return { args }; | ||
}, | ||
template: ` | ||
<div> | ||
<vs-progress color-scheme="red" :value="10"/> | ||
<vs-progress color-scheme="amber" :value="20"/> | ||
<vs-progress color-scheme="green" :value="30"/> | ||
<vs-progress color-scheme="teal" :value="40"/> | ||
<vs-progress color-scheme="blue" :value="50"/> | ||
<vs-progress color-scheme="indigo" :value="60"/> | ||
<vs-progress color-scheme="purple" :value="70"/> | ||
<vs-progress color-scheme="pink" :value="80"/> | ||
</div> | ||
`, | ||
}), | ||
}; | ||
|
||
export const Primary: Story = { | ||
render: (args: any) => ({ | ||
components: { VsProgress }, | ||
setup() { | ||
return { args }; | ||
}, | ||
template: ` | ||
<div> | ||
<vs-progress color-scheme="red" primary :value="20" :max="200"/> | ||
<vs-progress color-scheme="amber" primary :value="40" :max="200"/> | ||
<vs-progress color-scheme="green" primary :value="60" :max="200"/> | ||
<vs-progress color-scheme="teal" primary :value="80" :max="200"/> | ||
<vs-progress color-scheme="blue" primary :value="100" :max="200"/> | ||
<vs-progress color-scheme="indigo" primary :value="120" :max="200"/> | ||
<vs-progress color-scheme="purple" primary :value="140" :max="200"/> | ||
<vs-progress color-scheme="pink" primary :value="160" :max="200"/> | ||
</div> | ||
`, | ||
}), | ||
}; | ||
|
||
export const StyleSet: Story = { | ||
args: { | ||
styleSet: { width: '50%', height: '2rem', borderRadius: '0.1rem' }, | ||
}, | ||
}; | ||
|
||
export const PreDefinedStyleSet: Story = { | ||
args: { | ||
styleSet: 'myStyleSet', | ||
}, | ||
}; |
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