Skip to content

feat: add text.lineHeight + support css variable font sizes #115

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

Merged
merged 4 commits into from
Jun 11, 2025

Conversation

gka
Copy link
Contributor

@gka gka commented Jun 11, 2025

This pull request improves support for multiline text, CSS variables for font size and line height,

Enhancements to text rendering:

  • Support for multiline text and line height customization:

    • Added a lineHeight property to Text.svelte, allowing users to specify line height as a multiplier of font size. Default value set to 1.2.
  • Support for CSS variables in font size and line height:

    • Added utility functions maybeFromPixel and maybeFromRem to convert CSS values (e.g., px and rem) into numerical values.
    • Created an example (text/css-var.svelte) demonstrating the use of CSS variables for font size and line height in SVG text rendering.

@gka gka requested a review from Copilot June 11, 2025 12:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for a new lineHeight text option and CSS variable font sizes, enhancing how text is rendered and positioned.

  • Updated documentation to describe the new lineHeight option.
  • Introduced an example showcasing CSS variable usage for font sizes in a Svelte component.
  • Refactored text rendering by extracting multiline text logic into a helper component.

Reviewed Changes

Copilot reviewed 78 out of 78 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/routes/marks/text/+page.md Updated text options documentation with a new lineHeight property and clarified positioning channels.
src/routes/examples/text/css-var.svelte Added an example demonstrating CSS variable-driven font size usage.
src/lib/marks/helpers/MultilineText.svelte Introduced a new helper to handle multiline text, incorporating lineHeight support.
src/lib/marks/Text.svelte Updated to use the new MultilineText helper and set default lineHeight.
src/lib/helpers/resolve.ts Minor code refactoring.
src/lib/helpers/getBaseStyles.ts Added helper functions to interpret pixel and rem values.
Comments suppressed due to low confidence (1)

src/lib/marks/helpers/MultilineText.svelte:117

  • The default lineHeight value is set to 1.2 here, while the documentation and the defaults in Text.svelte suggest a value of 1.1. Consider aligning the default values across components to ensure consistent behavior.
const lineHeight = $derived( textLines.length > 1 ? (resolveProp(args.lineHeight, d.datum) ?? 1.2) : 0 )

Copy link

netlify bot commented Jun 11, 2025

Deploy Preview for svelteplot ready!

Name Link
🔨 Latest commit e492243
🔍 Latest deploy log https://app.netlify.com/projects/svelteplot/deploys/684976563ebd97000838ad6e
😎 Deploy Preview https://deploy-preview-115--svelteplot.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

📦 Preview package for this PR is published!

Version: 0.3.3-pr-115.0

Install it with:

npm install svelteplot@pr-115
# or install the specific version
npm install svelteplot@0.3.3-pr-115.0

Copy link

📦 Preview package for this PR is published!

Version: 0.3.3-pr-115.1

Install it with:

npm install svelteplot@pr-115
# or install the specific version
npm install svelteplot@0.3.3-pr-115.1

Copy link

📦 Preview package for this PR is published!

Version: 0.3.3-pr-115.2

Install it with:

npm install svelteplot@pr-115
# or install the specific version
npm install svelteplot@0.3.3-pr-115.2

@gka gka merged commit db996a4 into main Jun 11, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy