pharo-graphics / Toplo

A widget framework on top of Bloc
MIT License
19 stars 9 forks source link

#valueOfTokenNamed: is crappy #156

Open plantec opened 5 months ago

plantec commented 5 months ago

it is based on a string. we should kill it. and use message instead. example in material design: md.sys.color.shadow

this could be implemented with: md sys color shadow

thus, getting the value of a token is simply done through message sending.

Now we need also a kind of infrastructure to specify the object hierarchies. As an example, Style dictionary would be a good approach see https://github.com/amzn/style-dictionary

labordep commented 5 months ago

@Nyan11 👀

Ducasse commented 5 months ago

We can also use slots for this and I would avoid chaining md sys color shadow if this is just names. The first things would be to hide the use of valueOfTokenNamed: from the user and get "normal" variables.

Nyan11 commented 5 months ago

In Style Dictionary not all pathes are values. For example:

color-background-red can be equal in Pharo to ^Color red.

But, color-background do not return anything

Nyan11 commented 5 months ago

Therefor the chaining of messages is complicated because certain chains will return nothing.

Nyan11 commented 5 months ago

The current style sheet rules are like this:

self
    when: ToPressedLookEvent
    write: (self property: #'background-color')
    with: [ :e | e valueOfTokenNamed: #'color-primary-pressed' ]
    animation: nil.

I suggest to do something like this:

self
    when: ToPressedLookEvent
    write: self properties backgroundColor
    with: [ :e | e tokens colorPrimaryPressed ]
    animation: nil.
plantec commented 5 months ago

We can also use slots for this and I would avoid chaining md sys color shadow if this is just names. The first things would be to hide the use of valueOfTokenNamed: from the user and get "normal" variables.

I like chaining of message sends instead of flatten names because it matches a token organization. to be discussed :)

plantec commented 5 months ago

The current style sheet rules are like this:

self
  when: ToPressedLookEvent
  write: (self property: #'background-color')
  with: [ :e | e valueOfTokenNamed: #'color-primary-pressed' ]
  animation: nil.

I suggest to do something like this:

self
  when: ToPressedLookEvent
  write: self properties backgroundColor
  with: [ :e | e tokens colorPrimaryPressed ]
  animation: nil.
self
when: ToPressedLookEvent
write: self properties backgroundColor
with: [ :e | e palette primaryPressed ]
animation: nil.

but I have to dig more

Ducasse commented 5 months ago

could you talk with marcus because I would like him to think about this?

tinchodias commented 2 months ago

Hello, did something happens about this?

labordep commented 2 months ago

I think not (:

Ducasse commented 2 months ago

No but it would be great to use slot to abstract this string base API. @tinchodias could you ping marcus?