diff options
Diffstat (limited to 'src/components/atoms/images/logo')
| -rw-r--r-- | src/components/atoms/images/logo/index.ts | 1 | ||||
| -rw-r--r-- | src/components/atoms/images/logo/logo.module.scss | 28 | ||||
| -rw-r--r-- | src/components/atoms/images/logo/logo.stories.tsx | 34 | ||||
| -rw-r--r-- | src/components/atoms/images/logo/logo.test.tsx | 13 | ||||
| -rw-r--r-- | src/components/atoms/images/logo/logo.tsx | 46 |
5 files changed, 122 insertions, 0 deletions
diff --git a/src/components/atoms/images/logo/index.ts b/src/components/atoms/images/logo/index.ts new file mode 100644 index 0000000..cb6151d --- /dev/null +++ b/src/components/atoms/images/logo/index.ts @@ -0,0 +1 @@ +export * from './logo'; diff --git a/src/components/atoms/images/logo/logo.module.scss b/src/components/atoms/images/logo/logo.module.scss new file mode 100644 index 0000000..bd4ee90 --- /dev/null +++ b/src/components/atoms/images/logo/logo.module.scss @@ -0,0 +1,28 @@ +@use "../../../styles/abstracts/functions" as fun; + +.wrapper { + width: var(--logo-size, fun.convert-px(100)); + height: var(--logo-size, fun.convert-px(100)); + max-width: 100%; + max-height: 100%; +} + +.bg-left { + fill: var(--color-primary-light); +} + +.bg-right { + fill: var(--color-primary-dark); +} + +.letter { + fill: var(--color-fg-inverted); + stroke: var(--color-primary-darker); + stroke-width: 5; +} + +.letter-shadow { + fill: var(--color-shadow-darker); + stroke: var(--color-shadow-darker); + stroke-width: 5; +} diff --git a/src/components/atoms/images/logo/logo.stories.tsx b/src/components/atoms/images/logo/logo.stories.tsx new file mode 100644 index 0000000..cfccb65 --- /dev/null +++ b/src/components/atoms/images/logo/logo.stories.tsx @@ -0,0 +1,34 @@ +import type { ComponentMeta, ComponentStory } from '@storybook/react'; +import { Logo as LogoComponent } from './logo'; + +/** + * Logo - Storybook Meta + */ +export default { + title: 'Atoms/Images', + component: LogoComponent, + argTypes: { + heading: { + control: { + type: 'text', + }, + description: 'The SVG title.', + table: { + category: 'Accessibility', + }, + type: { + name: 'string', + required: false, + }, + }, + }, +} as ComponentMeta<typeof LogoComponent>; + +const Template: ComponentStory<typeof LogoComponent> = (args) => ( + <LogoComponent {...args} /> +); + +/** + * Images Stories - Logo + */ +export const Logo = Template.bind({}); diff --git a/src/components/atoms/images/logo/logo.test.tsx b/src/components/atoms/images/logo/logo.test.tsx new file mode 100644 index 0000000..26fe6c3 --- /dev/null +++ b/src/components/atoms/images/logo/logo.test.tsx @@ -0,0 +1,13 @@ +import { describe, expect, it } from '@jest/globals'; +import { render, screen as rtlScreen } from '@testing-library/react'; +import { Logo } from './logo'; + +describe('Logo', () => { + it('renders a logo with a title', () => { + const heading = 'enim quaerat veritatis'; + + render(<Logo heading={heading} />); + + expect(rtlScreen.getByRole('img')).toHaveAccessibleName(heading); + }); +}); diff --git a/src/components/atoms/images/logo/logo.tsx b/src/components/atoms/images/logo/logo.tsx new file mode 100644 index 0000000..5c575a5 --- /dev/null +++ b/src/components/atoms/images/logo/logo.tsx @@ -0,0 +1,46 @@ +/* eslint-disable react/jsx-no-literals */ +import type { FC, SVGAttributes } from 'react'; +import styles from './logo.module.scss'; + +export type LogoProps = Omit<SVGAttributes<SVGElement>, 'role'> & { + /** + * Define an accessible title for the logo. + */ + heading?: string; +}; + +/** + * Logo component. + * + * Render a SVG logo. + */ +export const Logo: FC<LogoProps> = ({ heading, ...props }) => ( + // eslint-disable-next-line jsx-a11y/prefer-tag-over-role -- Valid on SVG + <svg + {...props} + className={styles.wrapper} + role="img" + viewBox="0 0 512 512" + xmlns="http://www.w3.org/2000/svg" + > + {heading ? <title>{heading}</title> : null} + <path className={styles['bg-left']} d="M 0,0 H 506 L 0,506 Z" /> + <path className={styles['bg-right']} d="M 512,512 H 6 L 512,6 Z" /> + <path + className={styles['letter-shadow']} + d="m 66.049088,353.26557 h 57.233082 l 15.4763,-40.00476 h 56.64908 l 15.76831,40.00476 h 57.2331 L 196.28357,165.21398 h -58.10911 z m 80.009522,-79.42552 21.02441,-55.18904 21.02439,55.18904 z" + /> + <path + className={styles.letter} + d="m 59.569539,346.78602 h 57.233081 l 15.4763,-40.00476 H 188.928 l 15.76831,40.00476 h 57.2331 L 189.80402,158.73443 h -58.10911 z m 80.009521,-79.42552 21.02441,-55.18904 21.02439,55.18904 z" + /> + <path + className={styles['letter-shadow']} + d="m 288.84935,353.26557 h 54.89704 v -50.51696 h 40.88078 c 42.04881,0 68.91332,-28.61654 68.91332,-68.32931 0,-38.5447 -21.60841,-69.20532 -67.74528,-69.20532 h -96.94586 z m 54.89704,-92.56578 v -53.437 h 29.78458 c 16.35231,0 23.94446,10.51221 23.94446,27.15651 0,15.47629 -8.46817,26.28049 -25.40449,26.28049 z" + /> + <path + className={styles.letter} + d="m 282.3698,346.78602 h 54.89704 v -50.51696 h 40.88078 c 42.04881,0 68.91332,-28.61654 68.91332,-68.3293 0,-38.54471 -21.60841,-69.20533 -67.74528,-69.20533 H 282.3698 Z m 54.89704,-92.56578 v -53.437 h 29.78458 c 16.35231,0 23.94446,10.51221 23.94446,27.15652 0,15.47628 -8.46817,26.28048 -25.40449,26.28048 z" + /> + </svg> +); |
