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(web, web-react): Stabilization of ProductLogo #DS-1374 #1617

Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/web-react/scripts/entryPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const entryPoints = [
{ dirs: ['components', 'NoSsr'] },
{ dirs: ['components', 'Pagination'] },
{ dirs: ['components', 'Pill'] },
{ dirs: ['components', 'ProductLogo'] },
{ dirs: ['components', 'Radio'] },
{ dirs: ['components', 'ScrollView'] },
{ dirs: ['components', 'Select'] },
Expand All @@ -51,7 +52,6 @@ const entryPoints = [
{ dirs: ['components', 'UNSTABLE_Avatar'] },
{ dirs: ['components', 'UNSTABLE_EmptyState'] },
{ dirs: ['components', 'UNSTABLE_PartnerLogo'] },
{ dirs: ['components', 'UNSTABLE_ProductLogo'] },
{ dirs: ['components', 'UNSTABLE_Slider'] },
{ dirs: ['components', 'UNSTABLE_Toggle'] },
{ dirs: ['components', 'UNSTABLE_Truncate'] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import React from 'react';
import { useClassNamePrefix, useStyleProps } from '../../hooks';
import { SpiritProductLogoProps } from '../../types/productLogo';

const UNSTABLE_ProductLogo = (props: SpiritProductLogoProps) => {
const ProductLogo = (props: SpiritProductLogoProps) => {
const { children, ...restProps } = props;

const productLogoClass = useClassNamePrefix('UNSTABLE_ProductLogo');
const productLogoClass = useClassNamePrefix('ProductLogo');
const { styleProps, props: otherProps } = useStyleProps(restProps);

return (
Expand All @@ -18,4 +18,4 @@ const UNSTABLE_ProductLogo = (props: SpiritProductLogoProps) => {
);
};

export default UNSTABLE_ProductLogo;
export default ProductLogo;
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
# UNSTABLE ProductLogo

> ⚠️ This component is UNSTABLE. It may significantly change at any point in the future.
> Please use it with caution.
# ProductLogo

The ProductLogo component is used to display the logo of the product.

```jsx
import { UNSTABLE_ProductLogo } from '@spirit/web-react';
import { ProductLogo } from '@spirit/web-react';

<UNSTABLE_ProductLogo aria-label="Logo of the product">
<ProductLogo aria-label="Logo of the product">
<!-- Logo go here -->
</UNSTABLE_ProductLogo>;
</ProductLogo>;
```

## Content
Expand All @@ -20,9 +17,9 @@ The content of the ProductLogo component can be an image or svg.
### Image

```jsx
<UNSTABLE_ProductLogo aria-label="Logo of the product">
<ProductLogo aria-label="Logo of the product">
<img src="path-to-logo" alt="Product Logo" height="60px" width="120px" aria-hidden="true" />
</UNSTABLE_ProductLogo>
</ProductLogo>
```

ℹ️ Don't forget to add the `aria-label` attribute for accessible title.
Expand All @@ -33,11 +30,11 @@ to specify the `height` and `width` of the embedded image.
### SVG

```jsx
<UNSTABLE_ProductLogo aria-label="Logo of the product">
<ProductLogo aria-label="Logo of the product">
<svg width="300" height="130">
<rect width="200" height="100" x="10" y="10" rx="20" ry="20" fill="#fff" />
</svg>
</UNSTABLE_ProductLogo>
</ProductLogo>
```

ℹ️ Don't forget to add the `aria-label` attribute for accessible title.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ import React from 'react';
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest';
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest';
import { stylePropsTest } from '../../../../tests/providerTests/stylePropsTest';
import UNSTABLE_ProductLogo from '../UNSTABLE_ProductLogo';
import ProductLogo from '../ProductLogo';

describe('UNSTABLE_ProductLogo', () => {
classNamePrefixProviderTest(UNSTABLE_ProductLogo, 'UNSTABLE_ProductLogo');
describe('ProductLogo', () => {
classNamePrefixProviderTest(ProductLogo, 'ProductLogo');

stylePropsTest(UNSTABLE_ProductLogo);
stylePropsTest(ProductLogo);

restPropsTest(UNSTABLE_ProductLogo, 'div');
restPropsTest(ProductLogo, 'div');

it('should render children', () => {
render(<UNSTABLE_ProductLogo>Content</UNSTABLE_ProductLogo>);
render(<ProductLogo>Content</ProductLogo>);

expect(screen.getByText('Content')).toBeInTheDocument();
});

it('should have correct className', () => {
render(<UNSTABLE_ProductLogo>Content</UNSTABLE_ProductLogo>);
render(<ProductLogo>Content</ProductLogo>);

expect(screen.getByText('Content')).toHaveClass('UNSTABLE_ProductLogo');
expect(screen.getByText('Content')).toHaveClass('ProductLogo');
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import UNSTABLE_ProductLogo from '../UNSTABLE_ProductLogo';
import ProductLogo from '../ProductLogo';

export const defaultSvgLogo = (
<svg width="178" height="44" viewBox="0 0 178 44" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand Down Expand Up @@ -68,8 +68,6 @@ export const defaultSvgLogo = (
</svg>
);

const ProductLogoDefault = () => (
<UNSTABLE_ProductLogo aria-label="Logo of the JobBoard">{defaultSvgLogo}</UNSTABLE_ProductLogo>
);
const ProductLogoDefault = () => <ProductLogo aria-label="Logo of the JobBoard">{defaultSvgLogo}</ProductLogo>;

export default ProductLogoDefault;
4 changes: 4 additions & 0 deletions packages/web-react/src/components/ProductLogo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use client';

export * from './ProductLogo';
export { default as ProductLogo } from './ProductLogo';
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Markdown } from '@storybook/blocks';
import type { Meta, StoryObj } from '@storybook/react';
import React from 'react';
import { defaultSvgLogo } from '../demo/ProductLogoDefault';
import ProductLogo from '../ProductLogo';
import ReadMe from '../README.md';
import UNSTABLE_ProductLogo from '../UNSTABLE_ProductLogo';

const meta: Meta<typeof UNSTABLE_ProductLogo> = {
title: 'Experimental/UNSTABLE_ProductLogo',
component: UNSTABLE_ProductLogo,
const meta: Meta<typeof ProductLogo> = {
title: 'Components/ProductLogo',
component: ProductLogo,
parameters: {
docs: {
page: () => <Markdown>{ReadMe}</Markdown>,
Expand All @@ -19,8 +19,8 @@ const meta: Meta<typeof UNSTABLE_ProductLogo> = {
};

export default meta;
type Story = StoryObj<typeof UNSTABLE_ProductLogo>;
type Story = StoryObj<typeof ProductLogo>;

export const Default: Story = {
name: 'UNSTABLE_ProductLogo',
name: 'ProductLogo',
};

This file was deleted.

2 changes: 1 addition & 1 deletion packages/web-react/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export * from './Modal';
export * from './NoSsr';
export * from './Pagination';
export * from './Pill';
export * from './ProductLogo';
export * from './Radio';
export * from './ScrollView';
export * from './Select';
Expand All @@ -38,6 +39,5 @@ export * from './Toast';
export * from './Tooltip';
export * from './UNSTABLE_Avatar';
export * from './UNSTABLE_PartnerLogo';
export * from './UNSTABLE_ProductLogo';
export * from './UNSTABLE_Toggle';
export * from './VisuallyHidden';
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
# UNSTABLE ProductLogo

> ⚠️ This component is UNSTABLE. It may significantly change at any point in the future.
> Please use it with caution.
# ProductLogo

The ProductLogo component is used to display the logo of the product.

```html
<div class="UNSTABLE_ProductLogo" aria-label="Logo of the product">
<div class="ProductLogo" aria-label="Logo of the product">
<!-- Logo go here -->
</div>
```

## Inverted variant

You can add an `UNSTABLE_ProductLogo--inverted` modifier class to invert the color of the background.
You can add an `ProductLogo--inverted` modifier class to invert the color of the background.
It is necessary to insert the appropriate inverted logo variant as a children.

```html
<div class="UNSTABLE_ProductLogo UNSTABLE_ProductLogo--inverted" aria-label="Logo of the product">
<div class="ProductLogo ProductLogo--inverted" aria-label="Logo of the product">
<!-- Inverted logo go here -->
</div>
```
Expand All @@ -29,7 +26,7 @@ The content of the ProductLogo component can be an image or svg.
### Image

```html
<div class="UNSTABLE_ProductLogo" aria-label="Logo of the product">
<div class="ProductLogo" aria-label="Logo of the product">
<img src="path-to-logo" alt="Product Logo" height="60px" width="120px" aria-hidden="true" />
</div>
```
Expand All @@ -42,7 +39,7 @@ to specify the `height` and `width` of the embedded image.
### SVG

```html
<div class="UNSTABLE_ProductLogo" aria-label="Logo of the product">
<div class="ProductLogo" aria-label="Logo of the product">
<svg width="300" height="130">
<rect width="200" height="100" x="10" y="10" rx="20" ry="20" fill="#fff" />
</svg>
Expand All @@ -54,11 +51,11 @@ to specify the `height` and `width` of the embedded image.
## Full Example

```html
<div class="UNSTABLE_ProductLogo" aria-label="Logo of the product">
<div class="ProductLogo" aria-label="Logo of the product">
<img src="path-to-logo" alt="Product Logo" width="120" height="60" aria-hidden="true" />
</div>

<div class="UNSTABLE_ProductLogo">
<div class="ProductLogo">
<svg width="300" height="130">
<rect width="200" height="100" x="10" y="10" rx="20" ry="20" fill="#fff" />
</svg>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@use 'theme' as theme;

.UNSTABLE_ProductLogo {
.ProductLogo {
display: inline-block;
max-width: 100%;
}

.UNSTABLE_ProductLogo > img,
.UNSTABLE_ProductLogo > svg {
.ProductLogo > img,
.ProductLogo > svg {
width: auto;
height: theme.$logo-height;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<section class="UNSTABLE_Section">
<h2 class="docs-Heading">Default</h2>
<div aria-label="Logo of the JobBoard" class="UNSTABLE_ProductLogo">
<div aria-label="Logo of the JobBoard" class="ProductLogo">
<svg width="178" height="44" viewBox="0 0 178 44" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_19404_2964)">
<path fill-rule="evenodd" clip-rule="evenodd"
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/scss/components/ProductLogo/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@forward 'ProductLogo';

This file was deleted.

3 changes: 2 additions & 1 deletion packages/web/src/scss/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
// @forward 'Modal';
// @forward 'Pagination';
// @forward 'Pill';
@forward 'ProductLogo';

// @forward 'Radio';
// @forward 'ScrollView';
// @forward 'Select';
Expand All @@ -35,7 +37,6 @@
@forward 'UNSTABLE_Avatar';
@forward 'UNSTABLE_EmptyState';
@forward 'UNSTABLE_PartnerLogo';
@forward 'UNSTABLE_ProductLogo';
@forward 'UNSTABLE_Section';

// @forward 'UNSTABLE_Slider';
Expand Down
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