revelrylabs / harmonium

An opinionated React component framework for teams that move fast.
https://harmonium.revelry.co
MIT License
35 stars 47 forks source link

Harmonium Configuration #489

Closed bryanjos closed 4 years ago

bryanjos commented 4 years ago

We want to allow designers and developers a way to configure Harmonium design token values. This will allow for an easier way update values across Harmonium's supported platforms.

This will be done by adding 2 commands to Harmonium

harmonium init

Running the above command will place a file named harmonium.config.js into the current working directory. This JavaScript file will export an object containing properties that are configurable in Harmonium. The first iteration of the file will probably look something like this:

module.exports = {
  outputPath: "./harmonium-settings" //path to output created assets
  designTokens: {}  // All of the design tokens in harmonium
}

The outputPath property is where the created assets will be dumped

The designTokens property will contain all of harmonium's design tokens. This can be created by getting all the json files in the design-tokens folder and merging them together. The resulting object is what will be placed in designTokens property

harmonium init defaults by putting the config in the current working directory. By adding a path, the user can change the name and path.

harmonium init ./config/harmonium-config.js

harmonium build

Running harmonium build will take the harmonium.config.js file and use it to generate the assets. The created files will go into the outputPath value defined. This value can be overridden by using the --outputPath flag.

When harmonium build is executed. It should create a default config object and merge in the user's config into that. This should allow the user's configuration to only include the values they want to change, while leaving the others defaulted.

By default the command looks for harmonium.config.js in the current working directory. But if the name is different or it is at a different path, the user can use the --config flag to point to it

bryanjos commented 4 years ago

I'm thinking we can do something similar to tailwind https://tailwindcss.com/docs/configuration

oohnoitz commented 4 years ago

This looks good to me. Just curious how it'd mesh with the way the design tokens files are currently broken up and if there is a straight forward way of configuring without having to go through a bunch of files? Though I guess it's subject to change right now? Seems like tailwindcss has it all in one huge file. It's a bit straightforward with what the defaults are all in one place.

bryanjos commented 4 years ago

My thought is that if the user does like harmonium init then that would merge the json into one file and put that file in the person's project. From there they can update values, do harmonium build <output folder> and get assets placed in that directory

oohnoitz commented 4 years ago

Read the update and I'm good with this. Just some opinions/thoughts on the designTokens object...

I think we'll want to shape up the harmonium build process though? With the second option, we'll need to help point the end user in the right direction before a build is complete, though we can help them with changelogs?

We can think about the same for when harmonium init is ran too.

bryanjos commented 4 years ago

I think I understand. So it would be more like option 1. But init will build a file with all the design tokens with the default values. The end user can delete anything in there they don't want to update.

bryanjos commented 4 years ago

This is done. Closing