-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typography): implement typography component
- Loading branch information
Showing
5 changed files
with
174 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
8 changes: 8 additions & 0 deletions
8
packages/documentation/demos/typography/TypographyClasses.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,8 @@ | ||
<template> | ||
<p class="acv-title"> | ||
Title | ||
</p> | ||
<p class="acv-subtitle"> | ||
Subtitle | ||
</p> | ||
</template> |
26 changes: 26 additions & 0 deletions
26
packages/documentation/demos/typography/TypographyComponent.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,26 @@ | ||
<script setup> | ||
import AcvTypography from '@/components/typography/typography.vue'; | ||
</script> | ||
|
||
<template> | ||
<AcvTypography | ||
title="Typography component with title and subtitle" | ||
subtitle="This is subtitle" | ||
/> | ||
|
||
<AcvTypography | ||
title="Typography component with header-right" | ||
subtitle="This is subtitle" | ||
> | ||
<template #header-right> | ||
<div>Header Right</div> | ||
</template> | ||
</AcvTypography> | ||
|
||
<AcvTypography | ||
title="Typography component with text" | ||
subtitle="This is subtitle" | ||
> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
</AcvTypography> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
export interface AcvTypographyProps { | ||
/** | ||
* Typography title | ||
*/ | ||
title?: string | ||
|
||
/** | ||
* Typography subtitle | ||
*/ | ||
subtitle?: string | ||
|
||
/** | ||
* Typography text content | ||
*/ | ||
text?: string | ||
|
||
/** | ||
* Tag to use for title of the component | ||
* @defaultValue 'p' | ||
*/ | ||
titleTag?: string | ||
|
||
/** | ||
* Tag to use for subtitle of the component | ||
* @defaultValue 'p' | ||
*/ | ||
subtitleTag?: string | ||
|
||
/** | ||
* Tag to use for text rendered via `text` prop | ||
* @defaultValue 'p' | ||
*/ | ||
textTag?: string | ||
} | ||
|
||
export interface AcvTypographySlots { | ||
/** | ||
* Custom content for title | ||
*/ | ||
'title': (_: any) => null | ||
|
||
/** | ||
* Custom content for subtitle | ||
*/ | ||
'subtitle': (_: any) => null | ||
|
||
/** | ||
* Custom content on right side of title & subtitle. | ||
*/ | ||
'header-right': (_: any) => null | ||
|
||
/** | ||
* Custom content for text | ||
*/ | ||
'default': (_: any) => null | ||
} |
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,75 @@ | ||
<script lang="ts" setup> | ||
import type { AcvTypographyProps, AcvTypographySlots } from './typography'; | ||
defineOptions({ | ||
name: 'AcvTypography' | ||
}); | ||
const { | ||
title, | ||
subtitle, | ||
text, | ||
titleTag, | ||
subtitleTag, | ||
textTag | ||
} = withDefaults(defineProps<AcvTypographyProps>(), { | ||
titleTag: 'p', | ||
subtitleTag: 'p', | ||
textTag: 'p' | ||
}); | ||
defineSlots<AcvTypographySlots>(); | ||
</script> | ||
|
||
<template> | ||
<div class="acv-typography"> | ||
<div | ||
v-if="$slots.title || title || $slots.subtitle || subtitle || $slots['header-right']" | ||
class="title-wrapper" | ||
> | ||
<div class="flex-grow"> | ||
<Component | ||
:is="titleTag" | ||
v-if="title || $slots.title" | ||
class="acv-title" | ||
> | ||
<slot name="title"> | ||
{{ title }} | ||
</slot> | ||
</Component> | ||
<Component | ||
:is="subtitleTag" | ||
v-if="subtitle || $slots.subtitle" | ||
class="acv-subtitle" | ||
> | ||
<slot name="subtitle"> | ||
{{ subtitle }} | ||
</slot> | ||
</Component> | ||
</div> | ||
<slot name="header-right" /> | ||
</div> | ||
<Component | ||
:is="textTag" | ||
v-if="text || $slots.default" | ||
class="acv-text" | ||
> | ||
<slot> | ||
{{ text }} | ||
</slot> | ||
</Component> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.acv-typography { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1rem; | ||
.title-wrapper { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
} | ||
</style> |