Skip to content

Commit

Permalink
fixup! Feat(web-react): Introduce UNSTABLE_PartnerLogo component #DS-…
Browse files Browse the repository at this point in the history
…1357
  • Loading branch information
curdaj committed Jul 3, 2024
1 parent 1bd2096 commit 4da86e3
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions packages/web-react/src/components/UNSTABLE_PartnerLogo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ The PartnerLogo component is available in [sizes][dictionary-size].
</UNSTABLE_PartnerLogo>
```

## Without safe zone
## Disabled safe zone

The PartnerLogo component can be displayed without the safe zone (padding). Use `withoutSafeZone` prop to disable safe zone around logo.
The PartnerLogo component can be displayed without the safe zone (padding). Use `disableSafeZone` prop to disable safe zone around logo.

```jsx
<UNSTABLE_PartnerLogo aria-label="Logo of the partner" withoutSafeZone>
<UNSTABLE_PartnerLogo aria-label="Logo of the partner" disableSafeZone>
<!-- Logo go here -->
</UNSTABLE_PartnerLogo>
```
Expand Down Expand Up @@ -70,10 +70,10 @@ attribute is set on the container.
## API

| Name | Type | Default | Required | Description |
| ----------------- | ---------------------------------- | -------- | -------- | ------------------------------------------------------- |
|-------------------| ---------------------------------- | -------- | -------- | ------------------------------------------------------- |
| `children` | `ReactNode` | `null` || Content of the PartnerLogo |
| `size` | [Size dictionary][dictionary-size] | `medium` || Size of the PartnerLogo |
| `withoutSafeZone` | `boolean` | `false` || If true, the PartnerLogo is displayed without safe zone |
| `disableSafeZone` | `boolean` | `false` || If true, the PartnerLogo is displayed without safe zone |

The components accept [additional attributes][readme-additional-attributes].
If you need more control over the styling of a component, you can use [style props][readme-style-props]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { usePartnerLogoStyleProps } from './usePartnerLogoStyleProps';

const defaultProps: Partial<SpiritPartnerLogoProps> = {
size: 'medium',
withoutSafeZone: false,
disableSafeZone: false,
};

const UNSTABLE_PartnerLogo = (props: SpiritPartnerLogoProps) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ describe('UNSTABLE_PartnerLogo', () => {
});

it('should render without safe zone', () => {
render(<UNSTABLE_PartnerLogo withoutSafeZone>Content</UNSTABLE_PartnerLogo>);
render(<UNSTABLE_PartnerLogo disableSafeZone>Content</UNSTABLE_PartnerLogo>);

expect(screen.getByText('Content')).toHaveClass('UNSTABLE_PartnerLogo--withoutSafeZone');
expect(screen.getByText('Content')).toHaveClass('UNSTABLE_PartnerLogo--disableSafeZone');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ describe('usePartnerLogoStyleProps', () => {
});

it('should return without safe zone', () => {
const props = { withoutSafeZone: true };
const props = { disableSafeZone: true };
const { result } = renderHook(() => usePartnerLogoStyleProps(props));

expect(result.current.classProps).toBe('UNSTABLE_PartnerLogo UNSTABLE_PartnerLogo--withoutSafeZone');
expect(result.current.classProps).toBe('UNSTABLE_PartnerLogo UNSTABLE_PartnerLogo--disableSafeZone');
});
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import PartnerLogoDemoFactory from './PartnerLogoDemoFactory';

const PartnerLogoWithoutSafeZone = () => (
const PartnerLogoDisableSafeZone = () => (
<div style={{ display: 'flex', flexWrap: 'wrap' }}>
<PartnerLogoDemoFactory withoutSafeZone />
<PartnerLogoDemoFactory disableSafeZone />
</div>
);

export default PartnerLogoWithoutSafeZone;
export default PartnerLogoDisableSafeZone;
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React from 'react';
import ReactDOM from 'react-dom/client';
import DocsSection from '../../../../docs/DocsSections';
import PartnerLogoDefault from './PartnerLogoDefault';
import PartnerLogoWithoutSafeZone from './PartnerLogoWithoutSafeZone';
import PartnerLogoDisableSafeZone from './PartnerLogoDisableSafeZone';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<DocsSection title="Default" stackAlignment="stretch">
<PartnerLogoDefault />
</DocsSection>
<DocsSection title="Without safe zone" stackAlignment="stretch">
<PartnerLogoWithoutSafeZone />
<DocsSection title="Disabled safe zone" stackAlignment="stretch">
<PartnerLogoDisableSafeZone />
</DocsSection>
</React.StrictMode>,
);
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const meta: Meta<typeof UNSTABLE_PartnerLogo> = {
},
},
args: {
withoutSafeZone: false,
disableSafeZone: false,
children: (
<svg width="108" height="40" viewBox="0 0 108 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clipPath="url(#clip0_20364_10)">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ export interface PartnerLogoStyles<T> {
}

export function usePartnerLogoStyleProps(props: SpiritPartnerLogoProps): PartnerLogoStyles<SpiritPartnerLogoProps> {
const { size, withoutSafeZone } = props;
const { size, disableSafeZone } = props;

const partnerLogoClass = useClassNamePrefix('UNSTABLE_PartnerLogo');
const partnerLogoSizeClass = `${partnerLogoClass}--${size}`;
const partnerLogoWithoutSafeZoneClass = `${partnerLogoClass}--withoutSafeZone`;
const partnerLogoDisableSafeZoneClass = `${partnerLogoClass}--disableSafeZone`;
const classProps = classNames(partnerLogoClass, {
[partnerLogoSizeClass]: size,
[partnerLogoWithoutSafeZoneClass]: withoutSafeZone,
[partnerLogoDisableSafeZoneClass]: disableSafeZone,
});

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-react/src/types/partnerLogo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { ChildrenProps, SizesDictionaryType, StyleProps } from './shared';

export interface SpiritPartnerLogoProps<S = void> extends ChildrenProps, StyleProps {
size?: SizesDictionaryType<S> | S;
withoutSafeZone?: boolean;
disableSafeZone?: boolean;
}

0 comments on commit 4da86e3

Please sign in to comment.