-
Notifications
You must be signed in to change notification settings - Fork 1
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
LPS-116194 Add token-definition part 1 #119
Conversation
To conserve resources, the PR Tester does not automatically run for every pull. If your code changes were already tested in another pull, reference that pull in this pull so the test results can be analyzed. If your pull was never tested, comment "ci:test" to run the PR Tester for this pull. |
], | ||
"tokens": [ | ||
{ | ||
"ccp": "--white", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this is the only thing... @izaera, @ruben-pulido, @marcoscv-work, @wincent... thoughts on how to better model it now that we can see it?
I still think something like:
{
"editorType": "ColorPicker",
"label": "gray-100",
"mappings": {
"ccp": "gray-100"
"figma": {
"id": 200,
"value": "gray-100",
}
},
"name": "gray100Color",
"tokenCategoryName": "colors",
"tokenSetName": "general",
"type": "String"
}
We could make the CSS CustomProperties mapping as simple as a string to allow for more complex ones in the future.
We would need to decide if we want mappings
to be an indexed object as in the example or an array with mappingType
and mapping
properties. The second one is more verbose but also more readable...
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer indexed objects because:
- They enforce keys to be unique
- They let you index by key in O(1)
Said that, it is obvious that we can do whatever we want in the JSON and then transform it internally to suit our programming needs.
However, I don't know how easy/possible it is to enforce unique keys inside an array in JSON schema. That could be key...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering why we include custom mappings in this file:
- Because it's their final place and we want them to be here
- Because we don't know yet what to do with them and we are just proofing
@ruben-pulido seems to be aligned with me (as per private conversation) and thinks the reason is 2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, I don't know how easy/possible it is to enforce unique keys inside an array in JSON schema. That could be key...
The current specification of JSON schema does not allow it AFAIK.
There is an open issue asking for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other places in the portal where we want to guarantee uniqueness we are adding code to perform that check outside of the JSON schema validation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it will be way too easy for tokens to fall out of sync and have no mappings
That's a point too 🤔
My concern was that the person writing the tokens may not know anything about the mappings. It could even be that the mappings are not known at the stage where the theme is developed. But it is true that that problem may be fixed with a proper development workflow...
Maybe we can settle on adding mappings in the file and then let it be extended (after deployment of the theme) if needed.
In that case, we just need to decide if we want an array or an object...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well... seeing as we have a schema and indexed objects are not spec'd... looks like we'll have an array?
{
"editorType": "ColorPicker",
"label": "gray-100",
"mappings": [
{
"mappingType": "cssVariable",
"value": "gray-100"
}
],
"name": "gray100Color",
"tokenCategoryName": "colors",
"tokenSetName": "general",
"type": "String"
}
This, @ruben-pulido, @izaera, @eduardoallegrini? 👆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good to me. I'll update the token definition JSON schema in #99 accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"mappings": [
{
"mappingType": "cssVariable",
"value": "gray-100"
}
],
I'll use type
instead of mappingType
as the name of the field. Prefixing type
but not prefixing value
seems otherwise inconsistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example mentioned above will then be:
{
"editorType": "ColorPicker",
"label": "gray-100",
"mappings": [
{
"type": "cssVariable",
"value": "gray-100"
}
],
"name": "gray100Color",
"tokenCategoryName": "colors",
"tokenSetName": "general",
"type": "String"
}
@eduardoallegrini Can you modify token-definition.json
to include the change?
I have a question about the if (type === "Color") {
editor = ColorPicker;
type = String;
} |
], | ||
"tokens": [ | ||
{ | ||
"ccp": "--white", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "ccp" stand for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSS Custom Properties, it's not the most fancy name but it's the official one 🤷♂️ https://www.w3.org/TR/css-variables-1/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess CSS Custom Property
Another question: what are |
Other than my feedback in this thread, the rest LGTM. I would probably rename |
@eduardoallegrini Regarding your question: For example, a variable of We could even potentially allow more than one |
Just to give some feedback from an "outsider" perspective (ie. somebody who doesn't know much about our Custom CSS Properties implementation), this are the questions that I have in my mind as I read this:
|
Oh, and I forgot to mention, "layout" (set) + "colors" (categories) is a bit of a strange combination to me. We're using it in this PR for |
Ok, quickly from https://www.figma.com/file/R0ccjMTdAmU3t348wSTUUJ/LPS---115168---Style-Editor-02?node-id=30%3A16019
Arbitrary, however we want... probably through some heuristic based on importance and frequency of usage, but as of right now, just make a guess. |
modules/apps/frontend-theme/frontend-theme-classic/src/WEB-INF/token-definition.json
Outdated
Show resolved
Hide resolved
Awesome, that clears it up perfectly then. Based on the Figma, then perhaps we have some minor discrepancies in terminology:
and:
Not sure what the "source of truth" should be considered to be, but I do know that whenever the language for concepts is not consistent throughout all the levels of a system (eg. UI terminology, terminology at various levels inside the implementation, terminology inside data/configuration artifacts etc) that it can increase the cognitive load of working with the system. It's not always possible, of course, for everything to be in exact harmony, but insofar as it is possible, it is desirable to keep discrepancies to a minimum. |
I agree: |
I tried to follow the order of the notes https://www.notion.so/Stylebook-Variables-a919ebecc01046d5bb8f89e076842503
You are right! I don't know how to define them
I tried to copy the categories we defined in https://github.com/liferay/liferay-portal/blob/master/modules/apps/frontend-theme/frontend-theme-classic/src/css/custom_properties/_custom_properties_variables.scss |
This should be customer-data-ux-driven... so maybe ping the author of https://www.notion.so/Stylebook-Variables-a919ebecc01046d5bb8f89e076842503, Juan? :) |
What about |
Sounds OK to me since that seems to be a term commonly used (https://developer.mozilla.org/en-US/docs/Web/CSS/--*) |
@ruben-pulido Are all these changes included in the JSON schema or it has to be modified? |
I've updated the PR making the changes mentioned in the comments. I didn't modify the |
@izaera I'm going to modify the JSON schema to include the mapping as discussed here and will link it here once finished |
|
See liferay-frontend#119 (comment) for more information.
Closing here since it's been updated there |
See liferay-frontend#119 (comment) for more information.
See liferay-frontend#119 (comment) for more information.
See liferay-frontend#119 (comment) for more information.
See liferay-frontend#119 (comment) for more information.
See liferay-frontend#119 (comment) for more information.
See liferay-frontend#119 (comment) for more information.
Work in progress to be merged to #111