-
Notifications
You must be signed in to change notification settings - Fork 7
Conversation
I used this method for SVG insertion https://css-tricks.com/creating-svg-icon-system-react/
# Conflicts: # src/components/Footer.js # src/css/components/Footer.scss
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks 👌 to me. Thanks for posting the screenshots.
I feel like the URL redirect is a best practice as a long term solution (some people on stackexchange say so). Using a URL would allow us to detect the language the first time a user visits the site and do a redirect from the server. Also forgive me if you weren't looking for feedback on that stuff yet.
src/components/I18nBanner.js
Outdated
constructor(props) { | ||
super(props); | ||
this.state = { | ||
activeLanguage: locale().substring(0,2) || 'en', // we could |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/I18nBanner.js
Outdated
activeLanguage: languageAbbr, | ||
isOpen: false, | ||
}) | ||
console.log(this.state.activeLanguage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely not something for right now: if/when we do server redirects for language we should set a cookie here so the server will know the user has overridden the language from the browser settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/I18nBanner.js
Outdated
} | ||
|
||
render() { | ||
const displayedLanguageAmount = 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really minor, but since the number of shown languages doesn't change on each render, you can create a method that sets this.primaryLanguages and this.secondaryLanguages in the constructor. and then reference those two class vars in render.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, that makes sense.
src/css/components/I18nBanner.scss
Outdated
@@ -0,0 +1,74 @@ | |||
.coa-I18nBanner { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename this _I18nBanner.scss so it's treated as a partial. This will fix the missing scss var issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
src/css/components/I18nBanner.scss
Outdated
.coa-I18nBanner { | ||
width: 100%; | ||
background-color: $color-gray-light; | ||
padding: .7rem 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not use magic numbers and stick to the padding dimensions we have? $coa-space-level1 or $coa-space-level2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
src/css/components/I18nBanner.scss
Outdated
|
||
.coa-I18nBanner__prompt { | ||
display: none; | ||
font-size: 1.5rem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above, can we stick to using variables for defining sizes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool. Do we want to define these in _variables_coa.scss
? For now, I'm using the font size values set in _variables_uswds.scss
src/components/I18nBanner.js
Outdated
}; | ||
} | ||
|
||
languageClassName = (language) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SUUUUPER minor, can we update these functions to getLanguageClassName and getSecondaryLanguageMenuClassName? I like the action the function is performing to be REAAAALLLLY STUPID obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
src/components/I18nBanner.js
Outdated
onClick={this.setLangauage} lang={language.abbr} | ||
key={i} | ||
> | ||
<span className="coa-I18nBanner__language--hide-sm">{language.title}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of creating specific hide-sm classes can we create generic ones for breakpoints.
.hidden--sm --> display none for small width screens and higher
.hidden--md --> display none for medium width screens and higher
.visible--sm --> display none by default, display initial for small screens and higher
.visible--md --> display none by default, display initial for medium screens and higher
We can use our screen size variables to build these helpers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, I knew I was taking a step in that direction but was hesitant to commit to it. Thanks for calling it out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So as I started digging into how to create these helper classes, I thought it was pretty interesting how they are doing it now in Bootstrap v4:
Code: https://github.com/twbs/bootstrap/blob/7b766e1ad53b0c22de42dac04d2472f287334e2a/scss/utilities/_display.scss
Docs: https://getbootstrap.com/docs/4.0/utilities/display/#hiding-elements
Should we move in that direction?
src/components/I18nBanner.js
Outdated
<div className="coa-I18nBanner"> | ||
<div className="wrapper"> | ||
<div className="row"> | ||
<div className="col-md-4 col-xs coa-I18nBanner__prompt"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we try to nest things inside of grid classes so display properties and margin properties and stuff don't conflict.
so ... <div className="col-md-4 col-xs>.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
src/css/components/I18nBanner.scss
Outdated
} | ||
|
||
.coa-I18nBanner__prompt { | ||
display: none; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we use the visible--md helper instead of defining specific styles for hiding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅
const { size } = props | ||
|
||
return ( | ||
<svg width={size} height={size} viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg" aria-labelledby="title"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SHOW ME HOW TO MAKE SVG PEEEEEAS!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remind me when we are both back in the office. no magic here.
src/components/I18nBanner.js
Outdated
setLangauage = (e) => { | ||
e.stopPropagation(); | ||
e.nativeEvent.stopImmediatePropagation(); | ||
const languageAbbr = e.target.parentElement.lang; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this way of getting the element that's clicked seems highly coupled to the dom structure. maybe try e.currentTarget to get the element which had the handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, great point. I was trying to accommodate both the main list and secondary list markup which had a small difference in DOM structure. But you're right that this is brittle and would break if someone refactored the HTML and not this line 60. I'm changing the lang="foo"
attribute to live directly on the span
instead of the parent li
# Conflicts: # src/App.js # src/css/App.scss
Addresses part of #21. Punts on most of #35
This isn't totally functional yet. Just mainly focusing on the markup. The language choice doesn't persist and it is only stored in the state of this component when it should probably be managed at a higher level.
We still need to:
austin.gov/es
Not sure about the best long term approach there so I'm going to punt until we can investigate if Next.js has some patterns we should look into.