Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add letter spacing to Text elements #14

Merged
merged 10 commits into from
Dec 28, 2023
2 changes: 2 additions & 0 deletions apps/dashboard/src/components/EditorToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function EditorToolbar() {
fontFamily: 'Inter',
fontWeight: 400,
lineHeight: 1,
letterSpacing: 0,
fontSize: 50,
align: 'left',
}}>
Expand Down Expand Up @@ -99,6 +100,7 @@ export function EditorToolbar() {
fontFamily: 'Inter',
fontWeight: 400,
lineHeight: 1,
letterSpacing: 0,
fontSize: 50,
align: 'left',
}}>
Expand Down
7 changes: 6 additions & 1 deletion apps/dashboard/src/components/RightPanel/FontSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ export function FontSection({ selectedElement }: FontSectionProps) {
}} type="number" value={selectedElement.lineHeight}>
<LineHeightIcon />
</Input>
<Input max={5} min={0} onChange={() => { updateElement(selectedElement); }} type="number" value={0}>
<Input max={10} min={-10} onChange={value => {
updateElement({
...selectedElement,
letterSpacing: value,
});
}} type="number" value={selectedElement.letterSpacing}>
<LetterSpacingIcon />
</Input>
<Select onChange={value => {
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/lib/elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export function createElementStyle(element: OGElement): CSSProperties {
fontWeight: element.fontWeight,
fontSize: `${element.fontSize}px`,
lineHeight: element.lineHeight,
letterSpacing: `${element.letterSpacing}px`,
textAlign: element.align,
// By default, Satori sets a margin top and bottom on some elements:
// https://github.com/vercel/satori/blob/29fe2e4a9676a1ba41c361ec1a547d6de329b039/src/handler/presets.ts#L15
Expand Down
2 changes: 2 additions & 0 deletions apps/dashboard/src/lib/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const TEMPLATES = [
"fontFamily": "Montserrat",
"fontWeight": 600,
"lineHeight": 1,
"letterSpacing": 0,
"fontSize": 120,
"align": "left"
},
Expand All @@ -68,6 +69,7 @@ export const TEMPLATES = [
"fontFamily": "Montserrat",
"fontWeight": 600,
"lineHeight": 1,
"letterSpacing": 0,
"fontSize": 80,
"align": "left"
},
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface OGPElement {
fontWeight: number
fontSize: number
lineHeight: number
letterSpacing: number
align: 'left' | 'center' | 'right'
}

Expand Down