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(Logo): allow color override #1263

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 27 additions & 3 deletions src/__screenshot_tests__/logo-screenshot-test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import {openStoryPage, screen} from '../test-utils';

const SKINS = ['Movistar', 'O2', 'O2-new', 'Vivo', 'Vivo-new', 'Telefonica', 'Blau', 'Tu'] as const;
import type {KnownSkinName} from '../skins/types';

const SKINS: Array<KnownSkinName> = [
'Movistar',
'O2',
'O2-new',
'Vivo',
'Vivo-new',
'Telefonica',
'Blau',
'Tu',
];
const LOGO_TYPES = ['imagotype', 'vertical', 'isotype'];
const INVERSE_VALUES = [false, true];
const DARK_MODE_VALUES = [false, true];
Expand Down Expand Up @@ -38,11 +49,24 @@ test.each(getBrandLogoCases())(
}
);

test.each(SKINS)('Logo. Default brand with skin={%s}', async (skin) => {
test.each(SKINS)('Logo. Default brand with skin={%s}', async (skin: KnownSkinName) => {
await openStoryPage({
id: 'components-logo--default',
device: 'DESKTOP',
skin: skin as (typeof SKINS)[number],
skin,
});

const story = await screen.findByTestId('logo');

const image = await story.screenshot();
expect(image).toMatchImageSnapshot();
});

test.each(SKINS)('Logo with color override skin=%s', async (skin: KnownSkinName) => {
await openStoryPage({
id: 'components-logo--default',
skin,
args: {color: 'black', size: 64, type: 'imagotype'},
});

const story = await screen.findByTestId('logo');
Expand Down
13 changes: 12 additions & 1 deletion src/__stories__/logo-story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type Args = {
action: 'none' | 'onPress' | 'href' | 'to';
forceBrandLogo: boolean;
brand: 'Movistar' | 'O2' | 'O2-new' | 'Vivo' | 'Telefonica' | 'Blau' | 'Tu';
color: string;
};

const getLogoActionProps = (action: string) => {
Expand All @@ -42,11 +43,20 @@ const getLogoActionProps = (action: string) => {
: {};
};

export const Default: StoryComponent<Args> = ({type, size, inverse, action, forceBrandLogo, brand}) => {
export const Default: StoryComponent<Args> = ({
type,
size,
inverse,
action,
forceBrandLogo,
brand,
color,
}) => {
const logoProps = {
...getLogoActionProps(action),
type,
size,
color: color || undefined,
};

const CurrentLogo = {
Expand Down Expand Up @@ -78,6 +88,7 @@ Default.args = {
inverse: false,
forceBrandLogo: false,
brand: 'Movistar',
color: '',
Copy link
Contributor

Choose a reason for hiding this comment

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

instead of a empty box, I prefer to give a list of examples like in progress bar story
https://mistica-ekone7k5g-flows-projects-65bb050e.vercel.app/?path=/story/components-progress-bars--progress-bar-story

For example:
color: 'default' | 'neutralHigh' | 'neutralMedium' | '#000000';

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, done

};

Default.argTypes = {
Expand Down
12 changes: 9 additions & 3 deletions src/logo-blau.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@ import {calcInlineVars} from './logo-common';

import type {LogoImageProps} from './logo-common';

const BlauLogoImage = ({size, type, isDarkMode, isInverse}: LogoImageProps): JSX.Element => {
const BlauLogoImage = ({
size,
type,
isDarkMode,
isInverse,
color: colorProp,
}: LogoImageProps): JSX.Element => {
const {colors} = getBlauSkin();
const color = isInverse && !isDarkMode ? colors.inverse : colors.brand;
const colorSecondary = isInverse && !isDarkMode ? colors.inverse : colors.promo;
const color = colorProp || (isInverse && !isDarkMode ? colors.inverse : colors.brand);
const colorSecondary = colorProp || (isInverse && !isDarkMode ? colors.inverse : colors.promo);

if (type === 'vertical') {
return (
Expand Down
1 change: 1 addition & 0 deletions src/logo-common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export type LogoImageProps = {
type: LogoType;
isDarkMode: boolean;
isInverse: boolean;
color?: string;
};

export const calcInlineVars = (size: ByBreakpoint<number>): Record<string, string> => {
Expand Down
10 changes: 8 additions & 2 deletions src/logo-movistar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import {calcInlineVars} from './logo-common';

import type {LogoImageProps} from './logo-common';

const MovistarLogoImage = ({size, type, isDarkMode, isInverse}: LogoImageProps): JSX.Element => {
const MovistarLogoImage = ({
size,
type,
isDarkMode,
isInverse,
color: colorProp,
}: LogoImageProps): JSX.Element => {
const {colors} = getMovistarSkin();
const color = isInverse && !isDarkMode ? colors.inverse : colors.brand;
const color = colorProp || (isInverse && !isDarkMode ? colors.inverse : colors.brand);

if (type === 'vertical') {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/logo-o2-new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {calcInlineVars} from './logo-common';

import type {LogoImageProps} from './logo-common';

const O2NewLogoImage = ({size, isDarkMode, isInverse}: LogoImageProps): JSX.Element => {
const O2NewLogoImage = ({size, isDarkMode, isInverse, color: colorProp}: LogoImageProps): JSX.Element => {
const {colors} = getO2NewSkin();
const color = isInverse && !isDarkMode ? colors.inverse : colors.brand;
const color = colorProp || (isInverse && !isDarkMode ? colors.inverse : colors.brand);

return (
<svg
Expand Down
4 changes: 2 additions & 2 deletions src/logo-o2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {calcInlineVars} from './logo-common';

import type {LogoImageProps} from './logo-common';

const O2LogoImage = ({size, isDarkMode, isInverse}: LogoImageProps): JSX.Element => {
const O2LogoImage = ({size, isDarkMode, isInverse, color: colorProp}: LogoImageProps): JSX.Element => {
const {colors} = getO2Skin();
const color = isInverse && !isDarkMode ? colors.inverse : colors.brand;
const color = colorProp || (isInverse && !isDarkMode ? colors.inverse : colors.brand);

return (
<svg
Expand Down
10 changes: 8 additions & 2 deletions src/logo-telefonica.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import {calcInlineVars} from './logo-common';

import type {LogoImageProps} from './logo-common';

const TelefonicaLogoImage = ({size, type, isDarkMode, isInverse}: LogoImageProps): JSX.Element => {
const TelefonicaLogoImage = ({
size,
type,
isDarkMode,
isInverse,
color: colorProp,
}: LogoImageProps): JSX.Element => {
const {colors} = getTelefonicaSkin();
const color = isInverse && !isDarkMode ? colors.inverse : colors.brand;
const color = colorProp || (isInverse && !isDarkMode ? colors.inverse : colors.brand);

if (type === 'vertical') {
return (
Expand Down
5 changes: 3 additions & 2 deletions src/logo-tu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {calcInlineVars} from './logo-common';

import type {LogoImageProps} from './logo-common';

const TuLogoImage = ({size, isDarkMode, isInverse}: LogoImageProps): JSX.Element => {
const TuLogoImage = ({size, isDarkMode, isInverse, color: colorProp}: LogoImageProps): JSX.Element => {
const {colors} = getTuSkin();
const color = isDarkMode ? colors.inverse : isInverse ? colors.inverse : colors.backgroundBrand;
const color =
colorProp || (isDarkMode ? colors.inverse : isInverse ? colors.inverse : colors.backgroundBrand);

return (
<svg
Expand Down
10 changes: 8 additions & 2 deletions src/logo-vivo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import {calcInlineVars} from './logo-common';

import type {LogoImageProps} from './logo-common';

const VivoLogoImage = ({size, type, isInverse, isDarkMode}: LogoImageProps): JSX.Element => {
const VivoLogoImage = ({
size,
type,
isInverse,
isDarkMode,
color: colorProp,
}: LogoImageProps): JSX.Element => {
const {colors} = getVivoSkin();
const color = isInverse && !isDarkMode ? colors.inverse : colors.brand;
const color = colorProp || (isInverse && !isDarkMode ? colors.inverse : colors.brand);

if (type === 'vertical') {
return (
Expand Down
Loading
Loading