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

Export palette as CSS Variables #11

Merged
merged 4 commits into from
Jul 27, 2023
Merged

Export palette as CSS Variables #11

merged 4 commits into from
Jul 27, 2023

Conversation

HotFr1dge
Copy link
Contributor

In this Pull Request (PR), I would like to introduce a new feature to this repository that enables exporting the colour palette to CSS variables format. In my opinion, it's useful functionality and may reduce the time spent on copying and pasting all colours from the generator to CSS.

Changes introduced in the Pull Request (PR):

  1. CSS Variable Export Function:

    I added a new function called convertJSONtoCSS that converts the color palette from JSON format into CSS variables. This function processes each color and its shades, creating corresponding CSS variables. For each color, a variable is created in the format --clr-{colorName}-{shadeLabel}: {colorValue};, and a main variable for that color is also defined.

    Example:
    For the 'Primary' color, we obtain the defined CSS variables:

    --clr-primary-100: #112233;
    --clr-primary-200: #445566;
    --clr-primary: var(--clr-primary-200);
  2. No changes to the color format:
    The function currently accepts the color palette in HEX format, maintaining consistency with the existing application code.

  3. Testing:
    I conducted tests for the convertJSONtoCSS function and ensured that it correctly generates CSS variables for each color and its shades from the JSON-format palette. The tests were successful, and the function behaves as expected.

  4. Impact on existing code:
    The introduced changes do not negatively impact the existing code. The new function has been seamlessly integrated with the existing components and adapted to the current application logic.

  5. How it works in practice? User can export palette and select what type of export would get.

image
image

Copy link
Owner

@edelstone edelstone left a comment

Choose a reason for hiding this comment

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

Outside the two small issues I addressed inline (see below), this looks good and I think it's a great addition. Make those fixes and I'm happy to merge. I will also add a credit on the "about" page that calls you out as a contributor, if that's acceptable to you.

css/styles.css Show resolved Hide resolved
index.html Show resolved Hide resolved
@edelstone
Copy link
Owner

edelstone commented Jul 27, 2023

There is a small UI bug that was introduced by the addition of the select menu on mobile devices. This may not be something that will be easy for you to address, but if you want to try to fix it, go for it. I won't prevent a merge because of this. Notice the overflow of the text area at the bottom of the screen. This is using the iOS simulator on my MBP.

Screenshot 2023-07-27 at 12 07 01 PM

@edelstone edelstone merged commit 41bcb85 into edelstone:main Jul 27, 2023
@edelstone
Copy link
Owner

Thanks @HotFr1dge

@edelstone
Copy link
Owner

edelstone commented Jul 27, 2023

Credit added on about page and README. Thanks again. Really good stuff.

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.

2 participants