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

Shadows #86

Merged
merged 9 commits into from
May 31, 2020
Merged

Conversation

DeeLindesay
Copy link
Contributor

No description provided.

@rollingversions
Copy link

rollingversions bot commented May 22, 2020

@rollingversions/server (2.14.0 → 2.15.0)

New Features

  • Changing blue outlines on focus to orange/gray/white

Packages With No Changes

The following packages have no user facing changes, so won't be released:

  • rollingversions

Edit changelogs

Comment on lines +6 to +12
export function InstallButton({
size = 'sm',
shadow = 'gray',
}: {
size?: 'sm' | 'lg';
shadow?: 'gray' | 'orange' | 'white';
}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Constructing class names like this will break in production. Just accept a className?: string prop and add that into the class list.

The issue is that there's a production optimisation that checks each class name in the CSS to see if it's used in code, and removes the un-used css classes. It's not super smart, so it's just looking for occurrences of that string in the JavaScript code that's output, so it wont' be able to connect focus:shadow-${shadow} with the fact that you pass in shadow somewhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, but I've gone with setting shadow options to 'shadow-gray' rather than just 'gray' etc. This is because I want to default the shadow to 'shadow-gray' and className doesn't feel like it should just be defaulted if empty. Is this ok?

return (
<a
href="https://github.com/apps/rollingversions/installations/new"
className={`flex items-center justify-center bg-black text-white italic font-poppins font-black ${
className={`flex items-center justify-center bg-black text-white italic font-poppins font-black focus:outline-none focus:${shadow} ${
Copy link
Collaborator

Choose a reason for hiding this comment

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

The optimiser will not be able to look at focus:${shadow} and separately shadow="shadow-gray" and figure out that the focus:shadow-gray class is needed. You need the entire string focus:shadow-gray to appear somewhere. Since this is just a class name, the normal pattern is to allow the component to accept additional classes via an optional className property. The alternative is to have modes like shadow?: 'gray' | 'orange' | 'white' and then actually split them out to generate the classes via something like:

const shadowClasses = {
  gray: 'focus:shadow-gray',
  orange: 'focus:shadow-orange',
  white: 'focus:shadow-white',
};

The important thing is that the entire focus:shadow-x string needs to appear somewhere in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK

@ForbesLindesay ForbesLindesay merged commit bf811ac into RollingVersions:master May 31, 2020
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.

None yet

2 participants