Place spanish content on feature ?flags=sp (#1027)

- update snapshots
This commit is contained in:
Vim 2021-12-14 13:11:35 -05:00 committed by GitHub
commit 000da0f3ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 176 deletions

View file

@ -2,17 +2,32 @@ import React from 'react';
import {GovBanner} from '@trussworks/react-uswds'; import {GovBanner} from '@trussworks/react-uswds';
import {useIntl} from 'gatsby-plugin-intl'; import {useIntl} from 'gatsby-plugin-intl';
// Contexts:
import {useFlags} from '../../contexts/FlagContext';
import Language from '../Language'; import Language from '../Language';
import * as styles from './GovernmentBanner.module.scss'; import * as styles from './GovernmentBanner.module.scss';
const GovernmentBanner = () => { const GovernmentBanner = () => {
const intl = useIntl(); const intl = useIntl();
const flags = useFlags();
return ( return (
<div className={styles.fullScreenContainer}> <div className={styles.fullScreenContainer}>
<div className={styles.bannerContainer}> <div className={styles.bannerContainer}>
<GovBanner language={intl.locale === 'es' ? 'spanish' : 'english'}/>
<Language isDesktop={true}/> {'sp' in flags ? (
<>
<GovBanner language={intl.locale === 'es' ? 'spanish' : 'english'}/>
<Language isDesktop={true}/>
</>
) : (
<>
<GovBanner/>
</>
)}
</div> </div>
</div> </div>
); );

View file

@ -135,22 +135,6 @@ exports[`rendering of the GovernmentBanner checks if component renders 1`] = `
</div> </div>
</div> </div>
</section> </section>
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</div> </div>
</div> </div>
</DocumentFragment> </DocumentFragment>

View file

@ -140,22 +140,6 @@ exports[`rendering of the J40Header checks if component renders 1`] = `
</div> </div>
</div> </div>
</section> </section>
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</div> </div>
</div> </div>
<div> <div>
@ -277,24 +261,7 @@ exports[`rendering of the J40Header checks if component renders 1`] = `
<li <li
class="usa-nav__primary-item" class="usa-nav__primary-item"
> >
<div> <div />
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</div>
</li> </li>
</ul> </ul>
</nav> </nav>

View file

@ -1,6 +1,9 @@
import React from 'react'; import React from 'react';
import {IntlContextConsumer, changeLocale} from 'gatsby-plugin-intl'; import {IntlContextConsumer, changeLocale} from 'gatsby-plugin-intl';
// Contexts:
import {useFlags} from '../../contexts/FlagContext';
// @ts-ignore // @ts-ignore
import languageIcon from '/node_modules/uswds/dist/img/usa-icons/language.svg'; import languageIcon from '/node_modules/uswds/dist/img/usa-icons/language.svg';
import * as styles from './Language.module.scss'; import * as styles from './Language.module.scss';
@ -15,7 +18,9 @@ interface ILanguageProps {
} }
const Language = ({isDesktop}:ILanguageProps) => { const Language = ({isDesktop}:ILanguageProps) => {
return ( const flags = useFlags();
return 'sp' in flags ? (
<div className={isDesktop ? styles.languageContainer : styles.languageContainerMobile}> <div className={isDesktop ? styles.languageContainer : styles.languageContainerMobile}>
<img className={styles.languageIcon} src={languageIcon} alt={'language icon for selecting language'}/> <img className={styles.languageIcon} src={languageIcon} alt={'language icon for selecting language'}/>
<IntlContextConsumer> <IntlContextConsumer>
@ -33,7 +38,7 @@ const Language = ({isDesktop}:ILanguageProps) => {
} }
</IntlContextConsumer> </IntlContextConsumer>
</div> </div>
); ) : null;
}; };
export default Language; export default Language;

View file

@ -1,22 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`rendering of the Language checks if component renders 1`] = ` exports[`rendering of the Language checks if component renders 1`] = `<DocumentFragment />`;
<DocumentFragment>
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</DocumentFragment>
`;

View file

@ -140,22 +140,6 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis
</div> </div>
</div> </div>
</section> </section>
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</div> </div>
</div> </div>
<div> <div>
@ -277,24 +261,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis
<li <li
class="usa-nav__primary-item" class="usa-nav__primary-item"
> >
<div> <div />
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</div>
</li> </li>
</ul> </ul>
</nav> </nav>

View file

@ -140,22 +140,6 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis
</div> </div>
</div> </div>
</section> </section>
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</div> </div>
</div> </div>
<div> <div>
@ -277,24 +261,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis
<li <li
class="usa-nav__primary-item" class="usa-nav__primary-item"
> >
<div> <div />
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</div>
</li> </li>
</ul> </ul>
</nav> </nav>

View file

@ -140,22 +140,6 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis
</div> </div>
</div> </div>
</section> </section>
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</div> </div>
</div> </div>
<div> <div>
@ -277,24 +261,7 @@ exports[`rendering of the DatasetContainer checks if various text fields are vis
<li <li
class="usa-nav__primary-item" class="usa-nav__primary-item"
> >
<div> <div />
<div>
<img
alt="language icon for selecting language"
src="test-file-stub"
/>
<a
href="#"
>
English
</a>
<a
href="#"
>
Español
</a>
</div>
</div>
</li> </li>
</ul> </ul>
</nav> </nav>