figma-plugin icon indicating copy to clipboard operation
figma-plugin copied to clipboard

Add support for "full width" (100%) property

Open Copilot opened this issue 9 months ago • 4 comments

Overview

This PR adds support for the "full width" property, allowing users to apply sizing or dimension tokens with a value of "100%" to enhance layout flexibility.

Implementation Details

When a token with a value of "100%" is applied to a layer's width property:

  • For auto layout children: Sets layoutAlign to "STRETCH", making the element automatically fill the parent's width
  • For regular layers: Sets the width to match the parent element's width
  • Fallback behavior: If no suitable parent is found, handles the value like a regular sizing token

Example Use Cases

  • Design tokens defined with width: "100%" can be used to create responsive layouts
  • A common token can be applied across different hierarchy levels with context-aware behavior

Testing

  • Added unit tests covering all behavior patterns:
    • Normal width values
    • 100% width in auto layout parents
    • 100% width in regular parents
    • Fallback behavior
  • Verified no regression in existing functionality

Fixes #3377.

[!WARNING]

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cdn.fwupd.org
    • Triggering command: /usr/bin/fwupdmgr refresh (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar May 28 '25 06:05 Copilot

🦋 Changeset detected

Latest commit: 62bb377c1c563f3af3f2355c76dba41fbc589d20

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tokens-studio/figma-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar May 28 '25 06:05 changeset-bot[bot]

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

sonarqubecloud[bot] avatar May 29 '25 19:05 sonarqubecloud[bot]

Commit SHA:5e4542ef76a4e5e4dc7f6f9468eec02ce8d38297

Test coverage results :test_tube:

Code coverage diff between base branch:main and head branch: copilot/fix-3377 
Status File % Stmts % Branch % Funcs % Lines
:green_circle: total 65.39 (0.1) 57.27 (0.27) 62.54 (0.02) 65.74 (0.11)
:green_circle: packages/tokens-studio-for-figma/src/plugin/applySizingValuesOnNode.ts 90.19 (40.19) 76.47 (30.57) 100 (0) 90.19 (40.19)
:green_circle: packages/tokens-studio-for-figma/src/utils/isAutoLayout.tsx 100 (0) 100 (50) 100 (0) 100 (0)

github-actions[bot] avatar May 29 '25 19:05 github-actions[bot]

the logic you have right now for applying it - it repeats between width and height - lets extract to a function to call on both, with either width or height. like right now you have it in 3 places, bu...

Refactored the duplicated logic into a shared helper function handleFullSizeValue that handles 100% values for width, height, and both dimensions. The function consolidates the repeated logic across all three sections and includes proper TypeScript type guards. Commit 24b15c0.

Copilot avatar May 31 '25 18:05 Copilot

⤵️ 📦 ✨ The artifact was successfully created! Want to test it? Download it here 👀 🎁

github-actions[bot] avatar Jul 22 '25 16:07 github-actions[bot]