pharo-graphics / Toplo

A widget framework on top of Bloc
MIT License
17 stars 8 forks source link

#valueOfTokenNamed: is crappy #156

Open plantec opened 2 weeks ago

plantec commented 2 weeks 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 2 weeks ago

@Nyan11 👀

Ducasse commented 2 weeks 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 2 weeks 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 2 weeks ago

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

Nyan11 commented 2 weeks 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 2 weeks 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 2 weeks 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 2 weeks ago

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