Skip to content

Commit

Permalink
Returned default font size sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fsss126 committed May 2, 2024
1 parent c0e6614 commit c52d84e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/components/va-avatar/VaAvatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ defineExpose({
width: var(--va-avatar-size);
min-width: var(--va-avatar-size); // We only define width because common use case would be flex row, for column we expect user to set appropriate styling externally.
height: var(--va-avatar-size);
font-size: var(--va-avatar-font-size);
font-size: var(--va-avatar-font-size, var(--va-font-size));
&--small {
--va-avatar-size: 32px;
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/va-avatar/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
--va-avatar-position: relative;
--va-avatar-line-height: normal;
--va-avatar-border-radius: 50%;
--va-avatar-font-size: unset;

/* Medium */
--va-avatar-size: 48px;
Expand Down
10 changes: 7 additions & 3 deletions packages/ui/src/composables/useComponentVariables.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { cssVariableName } from '../utils/css-variables'
import { ReadonlyOrPlainArray } from '../utils/types/array'
import { computed, CSSProperties, getCurrentInstance } from 'vue'
import { isCSSSizeValue, isCSSVariable } from '../utils/css'
import isNil from 'lodash/isNil'
Expand All @@ -16,7 +15,7 @@ export const useComponentVariables = <Variables extends string>(props: SizeProps
throw new Error('Component name must be provided!')
}

const computedClass = useBem(componentName, () => {
const sizeModifierComputed = computed(() => {
const size = props.size

if (size && !(typeof size === 'string' && (isCSSVariable(size) || isCSSSizeValue(size)))) {
Expand All @@ -28,6 +27,11 @@ export const useComponentVariables = <Variables extends string>(props: SizeProps
return {}
})

const componentClass = useBem(componentName, sizeModifierComputed)
const fontClass = useBem('va-font-size', sizeModifierComputed)

const computedClass = computed(() => ({ ...fontClass.asObject.value, ...componentClass.asObject.value }))

const computedStyle = computed(() => {
const size = props.size

Expand Down Expand Up @@ -55,7 +59,7 @@ export const useComponentVariables = <Variables extends string>(props: SizeProps
})

return computed(() => ({
class: computedClass,
class: computedClass.value,
style: computedStyle.value,
}))
}
8 changes: 8 additions & 0 deletions packages/ui/src/styles/typography/typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
font-family: var(--va-font-family);
}

.va-font-size--small {
--va-font-size: var(--va-small-font-size);
}

.va-font-size--large {
--va-font-size: var(--va-large-font-size);
}

.va-typography-block {
font-family: var(--va-font-family);

Expand Down

0 comments on commit c52d84e

Please sign in to comment.