Skip to content

Commit

Permalink
fix(QFormItem): font weight, add labelClass
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey committed Apr 26, 2022
1 parent b942786 commit d2a5261
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/qComponents/QFormItem/src/QFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
v-if="label || $slots.label"
:for="labelFor"
class="q-form-item__label"
:class="{ 'q-form-item__label_small': isLabelSmall }"
:class="labelClass"
>
<slot name="label">{{ label }}</slot>
</label>
Expand Down Expand Up @@ -151,8 +151,6 @@ export default /* #__PURE__ */ defineComponent({
const labelFor = computed<Nullable<string>>(() => props.for ?? props.prop);
const isLabelSmall = computed<boolean>(() => props.labelSize === 'small');
const propRules = computed<FilteredRuleItem[]>(() => {
const rules =
props.rules ??
Expand All @@ -177,6 +175,10 @@ export default /* #__PURE__ */ defineComponent({
'q-form-item_is-no-asterisk': Boolean(qForm?.hideRequiredAsterisk.value)
}));
const labelClass = computed<string>(
() => `q-form-item__label_size_${props.labelSize}`
);
const getFilteredRules = (
trigger: Nullable<string>
): Nullable<FilteredRuleItem[]> => {
Expand Down Expand Up @@ -287,7 +289,7 @@ export default /* #__PURE__ */ defineComponent({
isRequired,
isHeaderShown,
rootClasses,
isLabelSmall,
labelClass,
getFilteredRules,
// for refs
validateField,
Expand Down
26 changes: 20 additions & 6 deletions src/qComponents/QFormItem/src/q-form-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,33 @@
&__label {
font-size: var(--font-size-base);
font-weight: var(--font-weight-base);
line-height: 18px;
color: var(--color-primary-black);

.q-form-item_is-required:not(.q-form-item_is-no-asterisk) &::after {
margin-left: 4px;
color: var(--color-secondary-orange);
content: '*';
}

&_small {
font-size: 10px;
line-height: 12px;
color: rgb(var(--color-rgb-gray) / 64%);
&_size {
&_regular {
font-size: 14px;
line-height: 18px;
color: var(--color-primary-black);

.q-form-item_is-required:not(.q-form-item_is-no-asterisk) &::after {
font-weight: 700;
}
}

&_small {
font-size: 10px;
line-height: 12px;
color: rgb(var(--color-rgb-gray) / 64%);

.q-form-item_is-required:not(.q-form-item_is-no-asterisk) &::after {
font-weight: 800;
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/qComponents/QFormItem/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ export interface QFormItemInstance {
}>
>;
resetField: () => void;
isLabelSmall: ComputedRef<boolean>;
labelClass: ComputedRef<string>;
}

0 comments on commit d2a5261

Please sign in to comment.