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

Add LocaleSwitcher #89

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Support for `localeSwitcher`.

## [2.18.0] - 2019-05-25

## [2.17.0] - 2019-04-29
### Added
- Added CSS Override class to header row background.

### Added
- Allow `drawer` block on `header-row`.
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,18 @@ Note that every `header` implementation must append all required blocks within i

Through the Storefront, you can change the headers's behavior and interface. However, you also can make in your theme app, as Store theme does.

| Prop name | Type | Description | Default value |
| ---------------------- | --------- | ------------------------------------------------- | ------------------------------------------------------------------------ |
| `leanWhen` | `String` | Cases in which the menu is in lean mode | 'a^' |
| `linkUrl` | `String` | Address opened when the user clicks the logo | '/' |
| `logoUrl` | `String` | URL of the logo image | N/A |
| `logoTitle` | `String` | Alt text for the logo | N/A |
| `logoSize` | `Object` | Sizes of logo in desktop and mobile | `desktop: { width: 132, height: 40 }, mobile: { width: 90, height: 40 }` |
| `showSearchBar` | `Boolean` | Sets whether the search bar is visible or not | true |
| `showLogin` | `Boolean` | Sets whether the login button is displayed or not | true |
| `iconClasses` | `String` | Classes for icons | 'c-on-base' |
| `labelClasses` | `String` | Classes for labels | 'c-on-base' |
| `collapsibleAnimation` | `Object` | Collapsible animation controlling | [Collapsible Animation](#collapsible-animation) |
| Prop name | Type | Description | Default value |
| ---------------------- | --------- | ---------------------------------------------------- | ------------------------------------------------------------------------ |
| `leanWhen` | `String` | Cases in which the menu is in lean mode | 'a^' |
| `linkUrl` | `String` | Address opened when the user clicks the logo | '/' |
| `logoUrl` | `String` | URL of the logo image | N/A |
| `logoTitle` | `String` | Alt text for the logo | N/A |
| `logoSize` | `Object` | Sizes of logo in desktop and mobile | `desktop: { width: 132, height: 40 }, mobile: { width: 90, height: 40 }` |
| `showSearchBar` | `Boolean` | Sets whether the search bar is visible or not | true |
| `showLogin` | `Boolean` | Sets whether the login button is displayed or not | true |
| `iconClasses` | `String` | Classes for icons | 'c-on-base' |
| `labelClasses` | `String` | Classes for labels | 'c-on-base' |
| `collapsibleAnimation` | `Object` | Collapsible animation controlling | [Collapsible Animation](#collapsible-animation) |

##### Collapsible Animation

Expand Down
5 changes: 3 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"vendor": "vtex",
"name": "store-header",
"version": "2.17.0",
"version": "2.18.0",
"title": "VTEX Store Header",
"defaultLocale": "pt-BR",
"description": "The VTEX Store Header component",
Expand All @@ -28,6 +28,7 @@
"vtex.store-components": "3.x",
"vtex.store-icons": "0.x",
"vtex.rich-text": "0.x",
"vtex.store-drawer": "0.x"
"vtex.store-drawer": "0.x",
"vtex.locale-switcher": "0.x"
}
}
1 change: 1 addition & 0 deletions messages/context.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"admin/editor.header.link.url": "admin/editor.header.link.url",
"admin/editor.header.show.searchbar.title": "admin/editor.header.show.searchbar.title",
"admin/editor.header.show.login.title": "admin/editor.header.show.login.title",
"admin/editor.header.show.localeswitcher.title": "admin/editor.header.show.localeswitcher.title",

Choose a reason for hiding this comment

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

Should this appear on /admin? It's not working for me

"store/header.search-placeholder": "store/header.search-placeholder",
"store/header.search-emptyPlaceholder": "store/header.search-emptyPlaceholder",
"store/header.topMenu.minicart.icon.label": "store/header.topMenu.minicart.icon.label",
Expand Down
1 change: 1 addition & 0 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"admin/editor.header.link.url": "Logo link",
"admin/editor.header.show.searchbar.title": "Show SearchBar",
"admin/editor.header.show.login.title": "Show Login",
"admin/editor.header.show.localeswitcher.title": "Show Locale Switcher",
"store/header.search-placeholder": "Search for products, brands...",
"store/header.search-emptyPlaceholder": "No matches found",
"store/header.topMenu.minicart.icon.label": "My Cart",
Expand Down
1 change: 1 addition & 0 deletions messages/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"admin/editor.header.logo.image": "Imagen del logotipo",
"admin/editor.header.link.url": "Link del logotipo",
"admin/editor.header.show.searchbar.title": "Mostrar Busca",
"admin/editor.header.show.localeswitcher.title": "Mostrar selector de localidade",
"admin/editor.header.show.login.title": "Mostrar Login",
"store/header.search-placeholder": "Búsqueda por productos, marcas...",
"store/header.search-emptyPlaceholder": "Ningún resultado encontrado",
Expand Down
1 change: 1 addition & 0 deletions messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"admin/editor.header.link.url": "Link da Logo",
"admin/editor.header.show.searchbar.title": "Mostrar Busca",
"admin/editor.header.show.login.title": "Mostrar Login",
"admin/editor.header.show.localeswitcher.title": "Mostrar seletor de localidade",
"store/header.search-placeholder": "Busque por produtos, marcas...",
"store/header.search-emptyPlaceholder": "Nenhum resultado encontrado",
"store/header.topMenu.minicart.icon.label": "Meu Carrinho",
Expand Down
20 changes: 20 additions & 0 deletions react/__tests__/__snapshots__/Header.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ exports[`Header Component should match snapshot mobile with leanmode 1`] = `
</div>
</div>
</div>
<div
class="extension-point-mock"
>
locale-switcher
</div>
<div
class="topMenuIcons flex justify-end flex-grow-1 flex-grow-0-ns items-center order-1-s ml-auto-s order-2-ns"
>
Expand Down Expand Up @@ -145,6 +150,11 @@ exports[`Header Component should match snapshot mobile without leanmode 1`] = `
</div>
</div>
</div>
<div
class="extension-point-mock"
>
locale-switcher
</div>
<div
class="topMenuIcons flex justify-end flex-grow-1 flex-grow-0-ns items-center order-1-s ml-auto-s order-2-ns"
>
Expand Down Expand Up @@ -241,6 +251,11 @@ exports[`Header Component should match snapshot with leanmode 1`] = `
</div>
</div>
</div>
<div
class="extension-point-mock"
>
locale-switcher
</div>
<div
class="topMenuIcons flex justify-end flex-grow-1 flex-grow-0-ns items-center order-1-s ml-auto-s order-2-ns"
>
Expand Down Expand Up @@ -339,6 +354,11 @@ exports[`Header Component should match snapshot without leanmode 1`] = `
</div>
</div>
</div>
<div
class="extension-point-mock"
>
locale-switcher
</div>
<div
class="topMenuIcons flex justify-end flex-grow-1 flex-grow-0-ns items-center order-1-s ml-auto-s order-2-ns"
>
Expand Down
4 changes: 3 additions & 1 deletion react/components/Row.css
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.headerRow {}
.headerRow {}
.headerRowBackground {}
.headerRowContainer {}
4 changes: 2 additions & 2 deletions react/components/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ const Row: FunctionComponent<Props & BlockClass> = ({
inverted,
blockClass,
}) => {
const content = <div className="w-100 flex items-center">{children}</div>
const content = <div className={`${styles.headerRowContainer} w-100 flex items-center`}>{children}</div>

return (
<StickyRow sticky={sticky}>
<div className={generateBlockClass(styles.headerRow, blockClass)}>
<div
className={classNames(
'w-100',
`${generateBlockClass(styles.headerRowBackground, blockClass)} w-100`,
inverted
? 'bg-base--inverted c-on-base--inverted'
: 'bg-base c-on-base'
Expand Down
2 changes: 2 additions & 0 deletions react/legacy/components/FixedContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ const FixedContent = ({
</div>
)}

<ExtensionPoint id="locale-switcher"/>

<Actions
iconClasses={iconClasses}
labelClasses={labelClasses}
Expand Down
2 changes: 2 additions & 0 deletions react/legacy/components/TopMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const TopMenu = ({
logoTitle,
logoSize,
showLogin,
showLocaleSwitcher,
showSearchBar,
iconClasses,
labelClasses,
Expand Down Expand Up @@ -44,6 +45,7 @@ const TopMenu = ({
logoTitle={logoTitle}
showSearchBar={showSearchBar}
showLogin={showLogin}
showLocaleSwitcher={showLocaleSwitcher}
iconClasses={iconClasses}
labelClasses={labelClasses}
mobile={mobile}
Expand Down
13 changes: 13 additions & 0 deletions react/legacy/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ export const icons = {
},
}

export const localeSwitcher = {
propTypes: {
showLocaleSwitcher: PropTypes.bool,
color: PropTypes.string,
hoverColor: PropTypes.string,
},
defaultProps: {
showLocaleSwitcher: true,
color: 'near-black',
hoverColor: 'rebel-pink',
}
}

export const collapsible = {
propTypes: {
collapsibleAnimation: PropTypes.shape({
Expand Down
12 changes: 11 additions & 1 deletion react/legacy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
import { ExtensionPoint, useRuntime } from 'vtex.render-runtime'
import TopMenu from './components/TopMenu'
import Spacer from './components/Helpers/Spacer'
import { logo, collapsible, icons, searchBar, login } from './defaults'
import { logo, collapsible, icons, searchBar, login, localeSwitcher } from './defaults'

import styles from './store-header.css'
import useDevice from './hooks/useDevice'
Expand All @@ -20,6 +20,7 @@ const Header = ({
logoSize,
showSearchBar,
showLogin,
showLocaleSwitcher,
iconClasses,
labelClasses,
collapsibleAnimation,
Expand All @@ -46,6 +47,7 @@ const Header = ({
logoSize,
showSearchBar,
showLogin,
showLocaleSwitcher,
iconClasses,
labelClasses,
collapsibleAnimation,
Expand Down Expand Up @@ -95,6 +97,7 @@ Header.propTypes = {
...icons.propTypes,
...logo.propTypes,
...collapsible.propTypes,
...localeSwitcher.propTypes,
}

Header.defaultProps = {
Expand All @@ -104,6 +107,7 @@ Header.defaultProps = {
...icons.defaultProps,
...logo.defaultProps,
...collapsible.defaultProps,
...localeSwitcher.defaultProps,
}

Header.schema = {
Expand Down Expand Up @@ -134,6 +138,12 @@ Header.schema = {
default: true,
isLayout: true,
},
showLocaleSwitcher: {
Copy link
Contributor

@GustavoMA GustavoMA May 23, 2019

Choose a reason for hiding this comment

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

I wasn't able to see this configuration in the storefront, can you take a look into that?

title: 'admin/editor.header.show.localeswitcher.title',
type: 'boolean',
default: true,
isLayout: true,
},
},
}

Expand Down
5 changes: 4 additions & 1 deletion store/blocks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"minicart",
"login",
"category-menu",
"search-bar"
"search-bar",
"locale-switcher"
]
},
"header-layout.desktop": {
Expand All @@ -34,6 +35,7 @@
"children": [
"header-spacer",
"search-bar",
"locale-switcher",
"header-spacer",
"login",
"minicart"
Expand Down Expand Up @@ -66,6 +68,7 @@
"children": [
"logo",
"search-bar",
"locale-switcher",
"login",
"minicart"
]
Expand Down
3 changes: 3 additions & 0 deletions store/interfaces.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"login",
"category-menu",
"search-bar",
"locale-switcher",
"theme",
"user-address",
"menu",
Expand Down Expand Up @@ -47,6 +48,7 @@
"minicart",
"login",
"search-bar",
"locale-switcher",
Copy link
Contributor

Choose a reason for hiding this comment

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

You should create an independent block for locale-switcher as well.

So it will work with the header-layout

"menu-link",
"category-menu",
"menu",
Expand Down Expand Up @@ -87,6 +89,7 @@
"minicart",
"login",
"search-bar",
"locale-switcher",
"menu-link",
"category-menu",
"menu",
Expand Down