-
-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Typography components (#146)
* feat: create text component * feat: components and docs * test: add tests
- Loading branch information
Showing
53 changed files
with
1,290 additions
and
58 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { defineComponent, computed } from 'vue' | ||
import { useNameHelper, useProps } from '@vexip-ui/config' | ||
|
||
import type { PropType } from 'vue' | ||
import type { TypographyType } from './symbol' | ||
|
||
export default defineComponent({ | ||
name: 'Blockquote', | ||
props: { | ||
type: String as PropType<TypographyType> | ||
}, | ||
emits: [], | ||
setup(_props, { slots }) { | ||
const props = useProps('blockquote', _props, { | ||
type: 'default' | ||
}) | ||
|
||
const nh = useNameHelper('blockquote') | ||
|
||
const className = computed(() => { | ||
return { | ||
[nh.b()]: true, | ||
[nh.bs('vars')]: true, | ||
[nh.bm(props.type)]: props.type !== 'default' | ||
} | ||
}) | ||
|
||
return () => <blockquote class={className.value}>{slots.default?.()}</blockquote> | ||
} | ||
}) |
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 @@ | ||
import { defineComponent } from 'vue' | ||
import Title from './title' | ||
import { useProps, booleanProp } from '@vexip-ui/config' | ||
|
||
import type { PropType } from 'vue' | ||
import type { TypographyType, TitleLevel } from './symbol' | ||
|
||
function createHComponent(level: TitleLevel) { | ||
return defineComponent({ | ||
name: `H${level}`, | ||
props: { | ||
type: String as PropType<TypographyType>, | ||
top: booleanProp, | ||
marker: booleanProp, | ||
aligned: booleanProp, | ||
thin: booleanProp, | ||
markerType: String as PropType<TypographyType> | ||
}, | ||
emits: [], | ||
setup(_props, { slots }) { | ||
const props = useProps('text', _props, { | ||
type: 'default', | ||
top: false, | ||
marker: false, | ||
aligned: false, | ||
thin: false | ||
}) | ||
|
||
return () => ( | ||
<Title {...props} level={level}> | ||
{slots.default?.()} | ||
</Title> | ||
) | ||
} | ||
}) | ||
} | ||
|
||
export const H1 = createHComponent(1) | ||
export const H2 = createHComponent(2) | ||
export const H3 = createHComponent(3) | ||
export const H4 = createHComponent(4) | ||
export const H5 = createHComponent(5) | ||
export const H6 = createHComponent(6) |
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,9 @@ | ||
export { default as Title } from './title' | ||
export { default as Text } from './text' | ||
export { default as Blockquote } from './blockquote' | ||
export { default as OL } from './ol' | ||
export { default as UL } from './ul' | ||
export { H1, H2, H3, H4, H5, H6 } from './h' | ||
export { default as P } from './p' | ||
export { default as Strong } from './strong' | ||
export type { TypographyType, TitleLevel } from './symbol' |
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,25 @@ | ||
import { defineComponent } from 'vue' | ||
import { useNameHelper, useProps } from '@vexip-ui/config' | ||
|
||
import type { PropType } from 'vue' | ||
|
||
export default defineComponent({ | ||
name: 'OL', | ||
props: { | ||
type: String as PropType<'a' | 'A' | 'i' | 'I' | '1'> | ||
}, | ||
emits: [], | ||
setup(_props, { slots }) { | ||
const props = useProps('text', _props, { | ||
type: '1' | ||
}) | ||
|
||
const nh = useNameHelper('ol') | ||
|
||
return () => ( | ||
<ol class={nh.b()} type={props.type}> | ||
{slots.default?.()} | ||
</ol> | ||
) | ||
} | ||
}) |
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 @@ | ||
import { defineComponent } from 'vue' | ||
import Text from './text' | ||
import { useProps, booleanProp } from '@vexip-ui/config' | ||
|
||
import type { PropType } from 'vue' | ||
import type { TypographyType } from './symbol' | ||
|
||
export default defineComponent({ | ||
name: 'P', | ||
props: { | ||
type: String as PropType<TypographyType>, | ||
delete: booleanProp, | ||
strong: booleanProp, | ||
italic: booleanProp, | ||
underline: booleanProp, | ||
mark: booleanProp, | ||
disabled: booleanProp, | ||
keyboard: booleanProp, | ||
thin: booleanProp, | ||
reversed: booleanProp | ||
}, | ||
emits: [], | ||
setup(_props, { slots }) { | ||
const props = useProps('text', _props, { | ||
type: 'default', | ||
delete: false, | ||
strong: false, | ||
italic: false, | ||
underline: false, | ||
mark: false, | ||
disabled: false, | ||
keyboard: false, | ||
thin: false, | ||
reversed: false | ||
}) | ||
|
||
return () => ( | ||
<Text {...props} tag={'p'}> | ||
{slots.default?.()} | ||
</Text> | ||
) | ||
} | ||
}) |
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,41 @@ | ||
import { defineComponent } from 'vue' | ||
import Text from './text' | ||
import { useProps, booleanProp } from '@vexip-ui/config' | ||
|
||
import type { PropType } from 'vue' | ||
import type { TypographyType } from './symbol' | ||
|
||
export default defineComponent({ | ||
name: 'Strong', | ||
props: { | ||
type: String as PropType<TypographyType>, | ||
delete: booleanProp, | ||
italic: booleanProp, | ||
underline: booleanProp, | ||
mark: booleanProp, | ||
disabled: booleanProp, | ||
keyboard: booleanProp, | ||
thin: booleanProp, | ||
reversed: booleanProp | ||
}, | ||
emits: [], | ||
setup(_props, { slots }) { | ||
const props = useProps('text', _props, { | ||
type: 'default', | ||
delete: false, | ||
italic: false, | ||
underline: false, | ||
mark: false, | ||
disabled: false, | ||
keyboard: false, | ||
thin: false, | ||
reversed: false | ||
}) | ||
|
||
return () => ( | ||
<Text {...props} tag={'strong'} strong> | ||
{slots.default?.()} | ||
</Text> | ||
) | ||
} | ||
}) |
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 @@ | ||
import '@/style/typography.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,2 @@ | ||
export type TypographyType = 'default' | 'primary' | 'info' | 'success' | 'warning' | 'error' | ||
export type TitleLevel = 1 | 2 | 3 | 4 | 5 | 6 |
Oops, something went wrong.