Skip to content

Commit

Permalink
SSR Footer: Use an empty state for Automattic branding before set the…
Browse files Browse the repository at this point in the history
… final value (#77916)

* Use an empty state for Automattic branding before set the final value

* Update the XautomatticBrandingNoun from a hook to a normal method
  • Loading branch information
WBerredo authored Jun 13, 2023
1 parent fce2cf2 commit ce98546
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/wpcom-template-parts/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type useAutomatticBrandingNoun from './hooks/use-automattic-branding-noun';
import type { getAutomatticBrandingNoun } from './utils';
import type { useLocalizeUrl } from '@automattic/i18n-utils';

export interface HeaderProps {
Expand All @@ -19,7 +19,7 @@ export interface PureFooterProps extends FooterProps {
localizeUrl?: ReturnType< typeof useLocalizeUrl >;
locale?: string;
isEnglishLocale?: boolean;
automatticBranding?: ReturnType< typeof useAutomatticBrandingNoun >;
automatticBranding?: ReturnType< typeof getAutomatticBrandingNoun >;
languageOptions?: LanguageOptions;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
useLocalizeUrl,
} from '@automattic/i18n-utils';
import { __ } from '@wordpress/i18n';
import { useTranslate } from 'i18n-calypso';
import { useLayoutEffect, useState } from 'react';
import SocialLogo from 'social-logos';
import useAutomatticBrandingNoun from '../hooks/use-automattic-branding-noun';
import { getAutomatticBrandingNoun } from '../utils';
import type { FooterProps, PureFooterProps, LanguageOptions } from '../types';

import './style.scss';
Expand Down Expand Up @@ -471,10 +473,15 @@ const UniversalNavbarFooter = ( {
}: FooterProps ) => {
const localizeUrl = useLocalizeUrl();
const locale = useLocale();
const translate = useTranslate();
const isEnglishLocale = useIsEnglishLocale();
const pathNameWithoutLocale =
currentRoute && removeLocaleFromPathLocaleInFront( currentRoute ).slice( 1 );
const automatticBranding = useAutomatticBrandingNoun();
const [ automatticBranding, setAutomatticBranding ] = useState( { article: '', noun: '' } );

useLayoutEffect( () => {
setAutomatticBranding( getAutomatticBrandingNoun( translate ) );
}, [ translate ] );

return (
<PureUniversalNavbarFooter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useTranslate } from 'i18n-calypso';
import { translate as translateMethod } from 'i18n-calypso';

const useAutomatticBrandingNoun = () => {
const translate = useTranslate();
export const getAutomatticBrandingNoun = ( translate: typeof translateMethod ) => {
const automatticRoger = [
translate( 'An Automattic brainchild' ),
translate( 'An Automattic contraption' ),
Expand All @@ -23,5 +22,3 @@ const useAutomatticBrandingNoun = () => {
noun: branding.split( 'Automattic' )[ 1 ],
};
};

export default useAutomatticBrandingNoun;

0 comments on commit ce98546

Please sign in to comment.