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(hero)!: convert to CSS modules #299

Merged
merged 12 commits into from
Sep 7, 2021
Merged

feat(hero)!: convert to CSS modules #299

merged 12 commits into from
Sep 7, 2021

Conversation

zchsh
Copy link
Contributor

@zchsh zchsh commented Aug 28, 2021

🎟️ Asana Task
πŸ” Preview Link


This PR updates @hashicorp/react-hero to use CSS modules.

PR Checklist πŸš€

Items in this checklist may not may not apply to your PR, but please consider each item carefully.

  • Add Asana and Preview links above.
  • Conduct thorough self-review.
  • Add or update tests as appropriate.
  • Conduct reasonable cross browser testing for both compatibility and responsive behavior (We have a Sauce Labs account for this, if you don't have access, just ask!).
  • Conduct reasonable accessibility review (use the WAS as a guide or an axe browser plugin until we establish more formal checks).
  • Identify (in the description above) and document (add Asana tasks on this board) any technical debt that you're aware of, but are not addressing as part of this PR.

@changeset-bot
Copy link

changeset-bot bot commented Aug 28, 2021

πŸ¦‹ Changeset detected

Latest commit: 68c8004

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@hashicorp/react-text-input Minor
@hashicorp/react-hero Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Aug 28, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

πŸ” Inspect: https://vercel.com/hashicorp/react-components/5u56SUEYWUNvsH78sfbheVN3jB7t
βœ… Preview: https://react-components-git-zshero-css-modules-hashicorp.vercel.app

@zchsh zchsh changed the base branch from main to zs.button-css-modules August 28, 2021 03:22
Base automatically changed from zs.button-css-modules to main August 31, 2021 14:46
@@ -226,6 +226,10 @@ module.exports = {
description: 'Whether or not to center the hero content',
testValue: false,
},
className: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added support for className, in case it's needed to deal with potential g-hero overrides.

'@hashicorp/react-text-input': minor
---

- ✨ Adds support for a className prop.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding className support to text-input was necessary to avoid a :global override selector previously used in hero.


const defaultProps = getTestValues(props)

it('should add a provided className to the root element', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the className prop in this PR, so felt right to add a corresponding test.

const error = form.touched[field.name] && form.errors[field.name]
// Label htmlFor relies on an id on the input field, which must be
// unique to prevent collisions between fields or forms on the same page
const inputId = 'u' + uuidv1()
return (
<div
className="g-text-input"
className={classNames('g-text-input', className)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Necessary to support hero-related styling.

@@ -15,7 +15,6 @@
@import '../packages/consent-manager/style.css';
@import '../packages/toggle/style.css';
@import '../packages/text-input/style.css';
@import '../packages/hero/style.css';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

πŸ”ͺ πŸŽ‰

@zchsh zchsh requested a review from a team September 2, 2021 19:08
@zchsh zchsh marked this pull request as ready for review September 2, 2021 19:08
Copy link
Contributor

@BRKalow BRKalow left a comment

Choose a reason for hiding this comment

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

πŸ‘

Comment on lines +94 to +97
className={classnames(s.videoWrapper, {
[s.isActive]: this.state.active === i,
[s.isDeactivating]: this.state.deactivating === i,
})}
Copy link
Contributor

Choose a reason for hiding this comment

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

clean!

position: relative;
transform: translateX(-60px);
line-height: 0;
box-shadow: 0 14.3254px 14.3254px rgba(37, 41, 55, 0.16);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow those are some crazy fractions!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah i'ma clean these up. As mentioned in other CSS comments, just flat out copy-pasted old styles for consistency, but this is pretty distracting πŸ‘


&.isActive {
opacity: 1;
padding-top: calc((100% * 0.63569) + 28px);
Copy link
Contributor

Choose a reason for hiding this comment

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

curious where this value came from πŸ’­

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll be honest, I have no idea - have just ported over old styles. Also curious, so I'll try to figure it out and add some comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

βœ… Okay so it's aspect ratio related - ensures there's no layout shift as the video loads. I added a clarifying comment here, and added a note on expected aspect ratio to props.js πŸ‘


.bar {
align-items: center;
background: #0e1016;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have color vars for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kind of - here's as-is, with the current hard-coded HEX values:

CleanShot 2021-09-03 at 16 52 28@2x

Closest var-friendly alternative with --black and --gray-1:

CleanShot 2021-09-03 at 16 54 50@2x

Definitely slightly different, but could definitely see the case for switching. I do worry a little about tying this tweak in with the modules change - even though it feels super minor, I think there are cases where it the difference would be noticeable, eg if the BG is full --black. So going to leave as-is for now, but definitely on board with rooting out HEX values in the future πŸ‘

width: 100%;

& span {
background: #252937;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have color vars for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Forgot to follow-up here - details in #299 (comment)

Comment on lines 43 to 44
/* Note: has-videos is only used in Percy on www-next. Should likely be removed */
{ 'has-videos': hasVideos },
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ‘

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing this now πŸ‘

Copy link
Contributor Author

Choose a reason for hiding this comment

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

βœ…

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