add line-height possibility

This commit is contained in:
Julie Blanc 2026-03-02 17:29:49 +01:00
parent eac7acdbc6
commit 154804ee44
2 changed files with 40 additions and 3 deletions

View file

@ -47,7 +47,7 @@
<div class="input-with-unit"> <div class="input-with-unit">
<NumberInput <NumberInput
v-model="fontSize.value" v-model="fontSize.value"
:min="0" :min="6"
:step="1" :step="1"
:disabled="inheritanceLocked" :disabled="inheritanceLocked"
/> />
@ -65,6 +65,33 @@
</div> </div>
</div> </div>
<!-- LineHeight -->
<div class="settings-subsection">
<div class="field" :class="{ 'field--view-only': inheritanceLocked }">
<label class="label-with-tooltip" data-css="line-height">Interlignage</label>
<div class="input-with-unit">
<NumberInput
v-model="lineHeight.value"
:min="0"
:step="1"
:disabled="inheritanceLocked"
/>
<div class="unit-toggle">
<button
type="button"
:class="{ active: lineHeight.unit === 'px' }"
:disabled="inheritanceLocked"
@click="updateUnitPropUnit(lineHeight, 'px')"
>
px
</button>
</div>
</div>
</div>
</div>
<!-- Text Alignment --> <!-- Text Alignment -->
<div class="settings-subsection"> <div class="settings-subsection">
<div class="field" :class="{ 'field--view-only': inheritanceLocked }"> <div class="field" :class="{ 'field--view-only': inheritanceLocked }">
@ -218,6 +245,7 @@ const textAlign = ref('left');
const color = ref('rgb(0, 0, 0)'); const color = ref('rgb(0, 0, 0)');
const background = ref('transparent'); const background = ref('transparent');
const fontSize = reactive({ value: 23, unit: 'px' }); const fontSize = reactive({ value: 23, unit: 'px' });
const lineHeight = reactive({ value: 28, unit: 'px' });
const marginOuter = reactive({ value: 0, unit: 'mm' }); const marginOuter = reactive({ value: 0, unit: 'mm' });
const paddingInner = reactive({ value: 0, unit: 'mm' }); const paddingInner = reactive({ value: 0, unit: 'mm' });
@ -242,6 +270,7 @@ const styleProps = [
const unitProps = [ const unitProps = [
{ css: 'font-size', ref: fontSize, debounce: true }, { css: 'font-size', ref: fontSize, debounce: true },
{ css: 'line-height', ref: lineHeight, debounce: true },
{ css: 'margin', ref: marginOuter, debounce: true }, { css: 'margin', ref: marginOuter, debounce: true },
{ css: 'padding', ref: paddingInner, debounce: true }, { css: 'padding', ref: paddingInner, debounce: true },
]; ];
@ -478,6 +507,12 @@ const toggleInheritance = () => {
fontSize.unit = fontSizeMatch[2]; fontSize.unit = fontSizeMatch[2];
} }
const lineHeightMatch = cs.lineHeight.match(/([\d.]+)(px|rem|em|pt)/);
if (lineHeightMatch) {
lineHeight.value = parseFloat(lineHeightMatch[1]);
lineHeight.unit = lineHeightMatch[2];
}
textAlign.value = cs.textAlign; textAlign.value = cs.textAlign;
color.value = cs.color; color.value = cs.color;
background.value = cs.backgroundColor; background.value = cs.backgroundColor;

View file

@ -89,15 +89,17 @@ const handleInput = (event) => {
emit('update:modelValue', value); emit('update:modelValue', value);
}; };
const decimals = (props.step.toString().split('.')[1] || '').length;
const increment = () => { const increment = () => {
const newValue = props.modelValue + props.step; const newValue = parseFloat((props.modelValue + props.step).toFixed(decimals));
if (props.max === undefined || newValue <= props.max) { if (props.max === undefined || newValue <= props.max) {
emit('update:modelValue', newValue); emit('update:modelValue', newValue);
} }
}; };
const decrement = () => { const decrement = () => {
const newValue = props.modelValue - props.step; const newValue = parseFloat((props.modelValue - props.step).toFixed(decimals));
if (props.min === undefined || newValue >= props.min) { if (props.min === undefined || newValue >= props.min) {
emit('update:modelValue', newValue); emit('update:modelValue', newValue);
} }