-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from LucasWerey/feat/10
Feat/10
- Loading branch information
Showing
13 changed files
with
254 additions
and
65 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
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
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 |
---|---|---|
@@ -1,59 +1,7 @@ | ||
<script setup lang="ts"> | ||
import './assets/index.css' | ||
import SnackBar from './components/Indicators/SnackBar' | ||
import Avatar from './components/Media/Avatar' | ||
import InputField from './components/CTA/InputField' | ||
const isVisible = ref(true) | ||
const consoleLog = (arg: boolean) => { | ||
isVisible.value = !arg | ||
return arg | ||
} | ||
const parentModel = ref('') | ||
const parentModel2 = ref('') | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<SnackBar | ||
type="info" | ||
size="medium" | ||
close="yes" | ||
@close="(arg) => consoleLog(arg)" | ||
:class="isVisible ? 'block' : 'translate-x-[100vw] ease-in-out duration-500'" | ||
> | ||
Lorem ipsum consectetur. Lorem ipsum consectetur. | ||
</SnackBar> | ||
<SnackBar | ||
type="validation" | ||
size="small" | ||
close="yes" | ||
@close="consoleLog" | ||
:class="isVisible ? 'block' : 'translate-x-[100vw] ease-in-out duration-500'" | ||
>Non</SnackBar | ||
> | ||
<SnackBar type="error" size="small" close="no">Oui</SnackBar> | ||
</div> | ||
|
||
<Avatar type="photo" size="xlarge" src="https://picsum.photos/200/300" alt="avatar" /> | ||
<Avatar type="notConnected" size="xlarge" /> | ||
<Avatar type="initial" size="xlarge">YO</Avatar> | ||
|
||
<InputField | ||
v-model="parentModel" | ||
placeholder="Email Address" | ||
label="Email" | ||
hint="Please enter without mistakes" | ||
|
||
/> | ||
|
||
<InputField | ||
v-model="parentModel2" | ||
placeholder="Email Address" | ||
label="Email" | ||
hint="Please enter without mistakes" | ||
size="big" | ||
/> | ||
<ChipContainer label="Espagnol" hasIcon /> | ||
</template> |
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
43 changes: 43 additions & 0 deletions
43
src/components/Containment/ChipContainer/ChipContainer.model.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,43 @@ | ||
/* | ||
Avaible colors: | ||
basic: | ||
black: '#1B1B1E', | ||
darkgrey: '#787878', | ||
grey: '#CDCDCD', | ||
lightgrey: '#ECECEC', | ||
verylightgrey: '#F6F6F6', | ||
white: '#FAFAFA' | ||
primary: | ||
DEFAULT: '#000000', | ||
light: '#00F2A5', | ||
charcoal: '#373F51', | ||
moonstone: '#58A4B0', | ||
powder: '#A9BCD0', | ||
platinum: '#D8DBE2' | ||
transparent: 'transparent', | ||
current: 'currentColor', | ||
inherit: 'inherit', | ||
error: '#FF5656', | ||
warning: '#FFC85C', | ||
success: '#7BC079', | ||
info: '#333333' | ||
*/ | ||
|
||
export const CHIP_CONTAINER_ICON_POSITION = { | ||
leading: 'leading', | ||
trailing: 'trailing' | ||
} as const | ||
|
||
export const CHIP_CONTAINER_ICON_POSITIONS = Object.values(CHIP_CONTAINER_ICON_POSITION) | ||
export type ChipContainerIconPosition = (typeof CHIP_CONTAINER_ICON_POSITIONS)[number] | ||
export const CHIP_CONTAINER_ICON_POSITION_DEFAULT = CHIP_CONTAINER_ICON_POSITION.trailing | ||
|
||
export const CHIP_CONTAINER_HAS_ICON = { | ||
true: true, | ||
false: false | ||
} as const | ||
|
||
export const CHIP_CONTAINER_HAS_ICONS = Object.values(CHIP_CONTAINER_HAS_ICON) | ||
export type ChipContainerHasIcon = (typeof CHIP_CONTAINER_HAS_ICONS)[number] | ||
export const CHIP_CONTAINER_HAS_ICON_DEFAULT = CHIP_CONTAINER_HAS_ICON.false |
54 changes: 54 additions & 0 deletions
54
src/components/Containment/ChipContainer/ChipContainer.spec.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,54 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { it, describe, expect } from 'vitest' | ||
import ChipContainer from './ChipContainer.vue' | ||
import { | ||
CHIP_CONTAINER_ICON_POSITION_DEFAULT, | ||
CHIP_CONTAINER_ICON_POSITION, | ||
CHIP_CONTAINER_HAS_ICON_DEFAULT | ||
} from './ChipContainer.model' | ||
|
||
describe('ChipContainer', () => { | ||
it('renders the label correctly', () => { | ||
const wrapper = mount(ChipContainer, { | ||
props: { | ||
label: 'Test label', | ||
iconPosition: CHIP_CONTAINER_ICON_POSITION_DEFAULT, | ||
hasIcon: CHIP_CONTAINER_HAS_ICON_DEFAULT | ||
} | ||
}) | ||
expect(wrapper.text()).toContain('Test label') | ||
}) | ||
|
||
it('renders the icon when hasIcon is true', () => { | ||
const wrapper = mount(ChipContainer, { | ||
props: { | ||
label: 'Test label', | ||
iconPosition: CHIP_CONTAINER_ICON_POSITION_DEFAULT, | ||
hasIcon: true | ||
} | ||
}) | ||
expect(wrapper.findComponent({ name: 'IconsBase' }).exists()).toBe(true) | ||
}) | ||
|
||
it('does not render the icon when hasIcon is false', () => { | ||
const wrapper = mount(ChipContainer, { | ||
props: { | ||
label: 'Test label', | ||
iconPosition: CHIP_CONTAINER_ICON_POSITION_DEFAULT, | ||
hasIcon: false | ||
} | ||
}) | ||
expect(wrapper.findComponent({ name: 'IconsBase' }).exists()).toBe(false) | ||
}) | ||
|
||
it('sets the correct icon position', () => { | ||
const wrapper = mount(ChipContainer, { | ||
props: { | ||
label: 'Test label', | ||
iconPosition: 'leading', | ||
hasIcon: true | ||
} | ||
}) as any | ||
expect(wrapper.classes()).toContain('flex-row-reverse') | ||
}) | ||
}) |
62 changes: 62 additions & 0 deletions
62
src/components/Containment/ChipContainer/ChipContainer.story.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,62 @@ | ||
<template> | ||
<Story title="Chip Container" group="containment"> | ||
<template #controls> | ||
<ControlDescription> | ||
<HstSelect | ||
v-model="controls.iconPosition" | ||
:options="Object.values(CHIP_CONTAINER_ICON_POSITION)" | ||
title="Icon Position" | ||
/> | ||
</ControlDescription> | ||
<ControlDescription> | ||
<HstCheckbox v-model="controls.hasIcon" title="Has Icon" /> | ||
</ControlDescription> | ||
<ControlDescription> | ||
<HstSelect v-model="controls.label" :options="labelOptions" title="Label" /> | ||
</ControlDescription> | ||
</template> | ||
|
||
<Variant title="Playground" auto-props-disabled> | ||
<ChipContainer | ||
:iconPosition="controls.iconPosition" | ||
:hasIcon="controls.hasIcon" | ||
:label="controls.label" | ||
/> | ||
</Variant> | ||
<Variant title="Default"> | ||
<ChipContainer label="Default" /> | ||
</Variant> | ||
<Variant title="With Icon" :auto-props-disabled="true"> | ||
<ChipContainer | ||
label="With Icon" | ||
:hasIcon="true" | ||
@deleteChip="logEvent('deleteChip', $event)" | ||
/> | ||
</Variant> | ||
</Story> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { logEvent } from 'histoire/client' | ||
import { | ||
CHIP_CONTAINER_ICON_POSITION_DEFAULT, | ||
CHIP_CONTAINER_ICON_POSITION, | ||
CHIP_CONTAINER_HAS_ICON_DEFAULT | ||
} from './ChipContainer.model' | ||
import type { ChipContainerIconPosition, ChipContainerHasIcon } from './ChipContainer.model' | ||
interface Controls { | ||
iconPosition: ChipContainerIconPosition | ||
hasIcon: ChipContainerHasIcon | ||
label: string | ||
} | ||
const controls = reactive<Controls>({ | ||
iconPosition: CHIP_CONTAINER_ICON_POSITION_DEFAULT, | ||
hasIcon: CHIP_CONTAINER_HAS_ICON_DEFAULT, | ||
label: 'Label 1' | ||
}) | ||
const labelOptions = ['Label 1', 'Label 2', 'Label 3', 'Label 4', 'Label 5'] | ||
</script> |
61 changes: 61 additions & 0 deletions
61
src/components/Containment/ChipContainer/ChipContainer.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,61 @@ | ||
<template> | ||
<div | ||
class="flex h-[22px] min-w-[69px] max-w-[95px] items-center justify-center justify-between gap-2 overflow-hidden rounded-lg border-[0.25px] border-primary-moonstone bg-primary-light bg-opacity-10 px-2 py-1 text-2 font-normal leading-5 text-primary-moonstone" | ||
:class="setIconPosition" | ||
> | ||
<div class="flex cursor-default overflow-hidden overflow-ellipsis whitespace-nowrap"> | ||
{{ label }} | ||
</div> | ||
<div | ||
v-if="hasIcon" | ||
class="flex h-[18px] w-[18px] cursor-pointer items-center overflow-y-hidden" | ||
:click="emit('deleteChip')" | ||
> | ||
<IconsBase name="close" class="h-full w-full" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { | ||
CHIP_CONTAINER_ICON_POSITION_DEFAULT, | ||
CHIP_CONTAINER_ICON_POSITION, | ||
CHIP_CONTAINER_HAS_ICON_DEFAULT, | ||
CHIP_CONTAINER_HAS_ICON | ||
} from './ChipContainer.model' | ||
import type { ChipContainerIconPosition, ChipContainerHasIcon } from './ChipContainer.model' | ||
const props = defineProps({ | ||
iconPosition: { | ||
type: String as PropType<ChipContainerIconPosition>, | ||
default: CHIP_CONTAINER_ICON_POSITION_DEFAULT, | ||
validator: (value: ChipContainerIconPosition) => { | ||
return Object.values(CHIP_CONTAINER_ICON_POSITION).includes(value) | ||
} | ||
}, | ||
hasIcon: { | ||
type: Boolean as PropType<ChipContainerHasIcon>, | ||
default: CHIP_CONTAINER_HAS_ICON_DEFAULT, | ||
validator: (value: ChipContainerHasIcon) => { | ||
return Object.values(CHIP_CONTAINER_HAS_ICON).includes(value) | ||
} | ||
}, | ||
label: { | ||
type: String as PropType<string>, | ||
default: '', | ||
required: true | ||
} | ||
}) | ||
const label = computed(() => props.label) | ||
const hasIcon = computed(() => props.hasIcon) | ||
const setIconPosition = computed(() => { | ||
return props.iconPosition === CHIP_CONTAINER_ICON_POSITION.trailing | ||
? 'flex-row' | ||
: 'flex-row-reverse' | ||
}) | ||
const emit = defineEmits(['deleteChip']) | ||
</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 @@ | ||
export { default } from './ChipContainer.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
Oops, something went wrong.