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

Feat(dictionary) Added new filter removePrivate #770

Merged
merged 9 commits into from
Feb 15, 2022

Conversation

silversonicaxel
Copy link
Contributor

@silversonicaxel silversonicaxel commented Feb 1, 2022

Description of changes:
This PR is intended to provide a new builtin filter functionality, called removePrivate, to allow to set a design token to private: true in order to avoid to be outputted in the distribution folder after the build process.

For example, having an initial source of design tokens like the following:

{
  'black': {
    'value': '#000000',
    'private': true
  },
  'aqua': {
    'value': '#00FFFF'
  },
  'white': {
    'value': '#FFFFFF',
    'private': false
  }
}

a potential scss output would be something like this:

$aqua: '#00FFFF';
$white: '#FFFFFF';

or a potential json output would be something like this:

{
  'aqua': '#00FFFF',
  'white': '#FFFFFF'
}

This PR is created as follow up of the discussion hold in this other PR #704 where the same feature was tried to be achieved with a different approach

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@silversonicaxel
Copy link
Contributor Author

For visibility I tag @chazzmoney

@silversonicaxel
Copy link
Contributor Author

Since you were interested, I tag also @crypt096, @caseybaggz and @didoo

@silversonicaxel
Copy link
Contributor Author

I still need to improve the documentation. I'll try by myself tomorrow, but any tips are more than welcome.

@silversonicaxel silversonicaxel changed the title Feat(dictionary) Added new filter removePrivate [WIP] Feat(dictionary) Added new filter removePrivate Feb 2, 2022
@silversonicaxel silversonicaxel changed the title [WIP] Feat(dictionary) Added new filter removePrivate Feat(dictionary) Added new filter removePrivate Feb 2, 2022
@silversonicaxel
Copy link
Contributor Author

Ready for review

Copy link
Member

@dbanksdesign dbanksdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for all your work on this! Just one minor thing with the example and we are good to go!

examples/advanced/filters/build.js Outdated Show resolved Hide resolved
examples/advanced/filters/package.json Outdated Show resolved Hide resolved
* @returns {Boolean}
*/
removePrivate: function(token) {
return (token && token.private) ? false : true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah so clean ✨

@@ -1,6 +1,5 @@
const fs = require('fs-extra');
const glob = require('glob');
const path = require('path');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -0,0 +1,99 @@
## Filters
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding an example!

var filters = require('../../lib/common/filters');

describe('common', () => {
describe('filters', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding unit tests!

Copy link
Collaborator

@chazzmoney chazzmoney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this! It is really nicely done.

After @dbanksdesign changes are complete, I'm ready to merge this!

Nice work.

@silversonicaxel
Copy link
Contributor Author

silversonicaxel commented Feb 4, 2022

FYI
Someone raise here ( design-tokens/community-group#110 (comment) ) some doubts regarding this approach, preferring the use of the 'private' key, as in the previous PR where all started.

Personally I don't mind this approach, more than the previous one. Up to you!

@chazzmoney
Copy link
Collaborator

@silversonicaxel I don't this the filter approach is in opposition; in fact, it is a simple change to make the filter run by default if the standards body decides that is a good idea and then publish it as a breaking change.

However, the final point in that discussion (that "private" may be an overloaded term with multiple meanings), is maybe a good one, which I wrote a response to here.

Do we really want to use "private"? Or should we try and use a more explicit property name?

@silversonicaxel
Copy link
Contributor Author

@chazzmoney I see your point, line is subtle. there are some options on the table I think.

in favour (and with a personal order preference) (I also believe that them all might be also overloaded with extra meanings)

  • private sounds the best choice, clear in its meaning
  • reserved could be enough clear, understandable
  • secret particular word, but also probably clear
  • hidden semantically I feel it slightly more confusing than the rest (hiding from what?)
  • filtered or filteredOut also possible

not in favour (since it tackles the other set of design tokens to keep in, and not filter out)

  • exported semantically good
  • exposed semantically good
  • visible semantically is not super clear

What do you think? @dbanksdesign also, your opinion?

Copy link
Member

@dbanksdesign dbanksdesign left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! :shipit:

I think because this is a filter and not changing core functionality and the filter name clearly says 'removePrivate' I am good with this change even if the spec goes a different route.

@chazzmoney chazzmoney merged commit 3217ba3 into amzn:main Feb 15, 2022
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

Successfully merging this pull request may close these issues.

3 participants