question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposing updates to the Toggle theme API

See original GitHub issue

Hi! This isn’t a bug report but rather a forum to get some feedback on some expansions I’d like to make to the Toggle component’s theming capability. I’m a new contributor but I’d be more than happy to take on these changes if they seem sound, as they would overlap well with stuff I’m working on at my company, which is a Grommet consumer. I read in the contribution guide that opening an issue is a good way to discuss plans, so here I am 😃

Problem

The current Checkbox Toggle styles are coupled in a few ways (but not in all ways) to the checkbox style - e.g. the width of the toggle is determined by theme.checkBox.toggle.size, but the height is determined by theme.checkBox.size; the size of the knob and style of the border are also coupled to the checkBox theme in similar ways. We’ve found it difficult to implement a toggle to design specifications without extensive use of the extend properties, sometimes to overwrite styles being applied because of what we put in the theme to style our checkboxes.

Proposed Changes

Given that the checkbox and toggle are visually very different components, I think it would be nice for Grommet to expose more toggle-specific theming options, and to use those options for styling (while falling back to checkbox styles where necessary to preserve backward compatibility). Specifically, I think I’d like to add the following to theme.checkBox.toggle (this all in addition to the existing theming API):

height?: string // height of the toggle background
// border for the toggle background
border?: {
  color?: ColorType;
  width?: string;
};
knob: {
  size?: string // size of the knob
}

I believe these additions would be sufficient to completely decouple the toggle styles from the checkbox styles. That said, as I mentioned above, we could coalesce back to the checkbox styles being used before, so this would not have to be a breaking change. My hope is that this would give a lot more clarity and ease for apps that use both a checkbox and a toggle while expecting them to look quite different.

Please let me know any thoughts that you have on this! Like I said, I haven’t contributed before, so I hope I’ve gone about this in the right way and am open to feedback of any sort 😃 Looking forward to hearing from you all.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
phinchcommented, Aug 5, 2021

got it, sounds good 😃 thanks @halocline. i’ll plan to start implementing a first pass at this tomorrow, taking all of the feedback into account! (will still be watching here for any other comments too)

1reaction
phinchcommented, Aug 4, 2021

@halocline thanks for the feedback 😃 here are some screenshots of each! The toggle height is 24px whereas the checkbox size is 20px; and the knob size is 16px. There’s also some atypical stuff in the toggle with the active/inactive color: it’s the background rather than the knob that changes color when active. I was also wondering about the checked state, which would definitely be used by us! it seems like the prevailing pattern in the Grommet checkbox is to use extend: ({ checked }) => ... to incorporate checked styles, which is definitely workable - but I think a checked section would be cool too if that sounds kosher.

our checkbox design: image image image

toggle design: image image image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Proposed API - Visual Studio Code
Proposed APIs are a set of unstable APIs that are implemented in VS Code but not exposed to the public as stable APIs...
Read more >
Feature Proposal: A New Experience for Discovering ...
This is the feature merge proposal for the new themes experience in the customizer introduced with #37661. Here's an overview of the current ......
Read more >
Propose to switch IDE appearance theme (Light/Dark) to ...
I mean changing the IDEA theme with the system theme, not using it. E.g. when windows use dark theme, then IDEA detects that...
Read more >
Experimental modules and themes in Drupal core
For example, an experimental extension can change between patch releases. ... When should I propose an experimental module or theme?
Read more >
A Guide to Themes - About Thunderbird
Dynamic themes are actually normal MailExtensions, that use the update() method of the theme API instead of a static theme manifest key. They...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found