-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/create-avatar-component
- Loading branch information
Showing
12 changed files
with
257 additions
and
0 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,8 @@ | ||
import { withInstall } from '@puik/utils' | ||
|
||
import Divider from './src/divider.vue' | ||
|
||
export const PuikDivider = withInstall(Divider) | ||
export default PuikDivider | ||
|
||
export * from './src/divider' |
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 { buildProps } from '@puik/utils' | ||
import type { ExtractPropTypes, PropType } from 'vue' | ||
import type Divider from './divider.vue' | ||
|
||
export enum PuikDividerOrientation { | ||
HORIZONTAL = 'horizontal', | ||
VERTICAL = 'vertical', | ||
} | ||
|
||
export const dividerOrientations = ['horizontal', 'vertical'] as const | ||
export type PuikDividerOrientationString = (typeof dividerOrientations)[number] | ||
|
||
export const dividerProps = buildProps({ | ||
orientation: { | ||
type: [ | ||
String as PropType<PuikDividerOrientation>, | ||
String as PropType<PuikDividerOrientationString>, | ||
], | ||
required: false, | ||
default: PuikDividerOrientation.HORIZONTAL, | ||
}, | ||
dataTest: { | ||
type: String, | ||
required: false, | ||
default: undefined, | ||
}, | ||
} as const) | ||
|
||
export type DividerProps = ExtractPropTypes<typeof dividerProps> | ||
|
||
export type DividerInstance = InstanceType<typeof Divider> |
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,22 @@ | ||
<template> | ||
<hr | ||
v-if="props.orientation === PuikDividerOrientation.HORIZONTAL" | ||
class="puik-divider puik-divider--horizontal" | ||
:data-test="dataTest" | ||
/> | ||
<div | ||
v-if="props.orientation === PuikDividerOrientation.VERTICAL" | ||
class="puik-divider puik-divider--vertical" | ||
:data-test="dataTest" | ||
></div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { dividerProps, PuikDividerOrientation } from './divider' | ||
defineOptions({ | ||
name: 'PuikDivider', | ||
}) | ||
const props = defineProps(dividerProps) | ||
</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,147 @@ | ||
import { dividerOrientations } from '../src/divider' | ||
import PuikDivider from './../src/divider.vue' | ||
import type { Meta, StoryFn, Args } from '@storybook/vue3' | ||
|
||
const dividerOrientationsSummary = dividerOrientations.join('|') | ||
|
||
export default { | ||
title: 'Components/Divider', | ||
component: PuikDivider, | ||
argTypes: { | ||
orientation: { | ||
description: | ||
'define the horizontal or vertical orientation of the divider component', | ||
control: 'select', | ||
options: dividerOrientations, | ||
table: { | ||
type: { | ||
summary: 'string', | ||
}, | ||
defaultValue: { | ||
summary: 'horizontal', | ||
}, | ||
}, | ||
}, | ||
dataTest: { | ||
description: 'set data-test attribute for e2e tests purpose', | ||
control: 'text', | ||
table: { | ||
type: { | ||
summary: 'string', | ||
}, | ||
defaultValue: { | ||
summary: 'undefined', | ||
}, | ||
}, | ||
}, | ||
}, | ||
args: {}, | ||
} as Meta | ||
|
||
const DefaultTemplate: StoryFn = (args: Args) => ({ | ||
components: { | ||
PuikDivider, | ||
}, | ||
setup() { | ||
return { args } | ||
}, | ||
template: `<puik-divider v-bind="args"/>`, | ||
}) | ||
|
||
const OrientationTemplate: StoryFn = (args: Args) => ({ | ||
components: { | ||
PuikDivider, | ||
}, | ||
setup() { | ||
return { args } | ||
}, | ||
template: ` | ||
<div style="display: flex; flex-direction: column; gap: 8px;"> | ||
<puik-divider orientation="horizontal"/> | ||
<div style="min-height: 96px; display: flex"> | ||
<puik-divider orientation="vertical"/> | ||
</div> | ||
</div> | ||
`, | ||
}) | ||
|
||
const DataTestTemplate: StoryFn = (args: Args) => ({ | ||
components: { | ||
PuikDivider, | ||
}, | ||
setup() { | ||
return { args } | ||
}, | ||
template: ` | ||
<div style="display: flex; flex-direction: column; gap: 8px;"> | ||
<puik-divider orientation="horizontal" dataTest="test"/> | ||
<div style="min-height: 96px; display: flex"> | ||
<puik-divider orientation="vertical" dataTest="test"/> | ||
</div> | ||
</div> | ||
`, | ||
}) | ||
|
||
export const Default = { | ||
render: DefaultTemplate, | ||
args: {}, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: ` | ||
<!-- VueJS Snippet --> | ||
<puik-divider /> | ||
<!-- HTML/CSS Snippet --> | ||
<hr class="puik-divider puik-divider--horizontal"> | ||
`, | ||
language: 'html', | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export const Orientation = { | ||
render: OrientationTemplate, | ||
args: {}, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: ` | ||
<!-- VueJS Snippet --> | ||
<!-- $orientations: ${dividerOrientationsSummary} --> | ||
<puik-divider orientation="{$size}"/> | ||
<!-- HTML/CSS Snippet --> | ||
<!-- $size = 'horizontal' --> | ||
<hr class="puik-divider puik-divider--horizontal"> | ||
<!-- $size = 'vertical' --> | ||
<div class="puik-divider puik-divider--vertical"></div> | ||
`, | ||
language: 'html', | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
export const DataTest = { | ||
render: DataTestTemplate, | ||
args: {}, | ||
parameters: { | ||
docs: { | ||
source: { | ||
code: ` | ||
<!-- VueJS Snippet --> | ||
<puik-divider orientation="{$size}" data-test="{$test}"/> | ||
<!-- HTML/CSS Snippet --> | ||
<!-- $size = 'horizontal' --> | ||
<hr class="puik-divider puik-divider--horizontal" data-test="horizontal-{$test}"> | ||
<!-- $size = 'vertical' --> | ||
<div class="puik-divider puik-divider--vertical" data-test="vertical-{$test}"></div> | ||
`, | ||
language: 'html', | ||
}, | ||
}, | ||
}, | ||
} |
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,2 @@ | ||
import '@puik/components/base/style/css' | ||
import '@puik/theme/puik-divider.css' |
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,2 @@ | ||
import '@puik/components/base/style' | ||
import '@puik/theme/src/divider.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,34 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { describe, it, expect } from 'vitest' | ||
import PuikDivider from '../src/divider.vue' | ||
import type { MountingOptions, VueWrapper } from '@vue/test-utils' | ||
|
||
describe('Divider tests', () => { | ||
let wrapper: VueWrapper<any> | ||
const findDivider = () => wrapper.find('.puik-divider') | ||
const factory = ( | ||
propsData: Record<string, any> = {}, | ||
options: MountingOptions<any> = {} | ||
) => { | ||
wrapper = mount(PuikDivider, { | ||
props: { | ||
...propsData, | ||
}, | ||
...options, | ||
}) | ||
} | ||
it('should be a vue instance', () => { | ||
factory() | ||
expect(wrapper).toBeTruthy() | ||
}) | ||
|
||
it('should be a vertical divider', () => { | ||
factory({ orientation: 'vertical' }) | ||
expect(findDivider().classes()).toContain('puik-divider--vertical') | ||
}) | ||
|
||
it('the value of the data-test attribute should be "test"', () => { | ||
factory({ orientation: 'vertical', dataTest: 'test' }) | ||
expect(findDivider().attributes('data-test')).toBe('test') | ||
}) | ||
}) |
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
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,6 @@ | ||
.puik-divider--horizontal { | ||
@apply text-primary-400; | ||
} | ||
.puik-divider--vertical { | ||
@apply bg-primary-400 w-[1px] min-h-full; | ||
} |
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 |
---|---|---|
|
@@ -43,3 +43,4 @@ | |
@use 'chip'; | ||
@use 'tag'; | ||
@use 'avatar'; | ||
@use 'divider'; |
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