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

Where is borderSide.width.ref ? #544

Open
lvsecoto opened this issue Dec 7, 2024 · 4 comments
Open

Where is borderSide.width.ref ? #544

lvsecoto opened this issue Dec 7, 2024 · 4 comments

Comments

@lvsecoto
Copy link

lvsecoto commented Dec 7, 2024

Use case

I want to borderSide.with can use Token

Proposal

Like this

$box.border.width.ref(token.container.border.thickness.$4)
@lvsecoto
Copy link
Author

lvsecoto commented Dec 7, 2024

I forked a branch

And modify packages/mix/lib/src/attributes/border/border_dto.g.dart BorderSideDTO

      color: _$this.color?.resolve(mix) ?? defaultValue.color,
      strokeAlign: _$this.strokeAlign ?? defaultValue.strokeAlign,
      style: _$this.style ?? defaultValue.style,
-      width: _$this.width ?? defaultValue.width,
+      width: mix.tokens.spaceTokenRef(_$this.width ?? defaultValue.width),
    );
  }

And also extend DoubleUtilty<T>

extension DoubleUtilsEx<T extends Attribute> on DoubleUtility<T> {
  T ref(SpaceToken ref) => builder(ref());
}

It is work.

There are a lot of attributes can use "NumberToken", like SizeBox.width.

@tilucasoli
Copy link
Collaborator

Thank you, @lvsecoto. This is an interesting point. We are currently studying a way to create tokens for all kinds of attributes.

#535

@tilucasoli
Copy link
Collaborator

The space token was created to serve as a specific token for spacement, not as a generic double token. The main point is that it could be used for any double attribute. We should consider making it more generic and flexible, perhaps calling it a DoubleToken instead of a SpaceToken, allowing any double property to accept it.

@tilucasoli
Copy link
Collaborator

For now, you could resolve the token using context,

$box.border.width(token.container.border.thickness.$4.resolve(context))

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

No branches or pull requests

2 participants