Skip to content

Commit

Permalink
fixup! Feat(web-react): Introduce UNSTABLE_Header #DS-1524
Browse files Browse the repository at this point in the history
  • Loading branch information
curdaj committed Dec 14, 2024
1 parent 3356270 commit 1500a68
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The `UNSTABLE_Header` component is planned to replace the `Header` component in the future.

This component provides these components:
The `UNSTABLE_Header` is a composition of several subcomponents:

- [UNSTABLE_Header](#unstable-header)
- [UNSTABLE_HeaderLogo](#unstable-headerlogo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import classNames from 'classnames';
import React from 'react';
import { useStyleProps } from '../../hooks';
import { SpiritHeaderProps } from '../../types';
import { useHeaderStyleProps } from './useHeaderStyleProps';
import { useUnstableHeaderStyleProps } from './useUnstableHeaderStyleProps';

const UNSTABLE_Header = (props: SpiritHeaderProps): JSX.Element => {
const { children, ...restProps } = props;

const { classProps, props: modifiedProps } = useHeaderStyleProps(restProps);
const { classProps, props: modifiedProps } = useUnstableHeaderStyleProps(restProps);
const { styleProps, props: otherProps } = useStyleProps(modifiedProps);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import classNames from 'classnames';
import React, { ElementType, forwardRef } from 'react';
import { useStyleProps } from '../../hooks';
import { PolymorphicRef, SpiritHeaderLogoProps } from '../../types';
import { useHeaderStyleProps } from './useHeaderStyleProps';
import { useUnstableHeaderStyleProps } from './useUnstableHeaderStyleProps';

const defaultProps: Partial<SpiritHeaderLogoProps> = {
elementType: 'a',
Expand All @@ -22,7 +22,7 @@ const _HeaderLogo = <E extends ElementType = 'a'>(
children,
...restProps
} = propsWithDefaults;
const { classProps, props: modifiedProps } = useHeaderStyleProps(restProps);
const { classProps, props: modifiedProps } = useUnstableHeaderStyleProps(restProps);
const { styleProps, props: otherProps } = useStyleProps(modifiedProps);

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { renderHook } from '@testing-library/react';
import { useHeaderStyleProps } from '../useHeaderStyleProps';
import { useUnstableHeaderStyleProps } from '../useUnstableHeaderStyleProps';

describe('useHeaderStyleProps', () => {
describe('useUnstableHeaderStyleProps', () => {
it('should return defaults', () => {
const props = {};
const { result } = renderHook(() => useHeaderStyleProps(props));
const { result } = renderHook(() => useUnstableHeaderStyleProps(props));

expect(result.current.classProps.root).toBe('UNSTABLE_Header');
expect(result.current.classProps.logo).toBe('UNSTABLE_HeaderLogo');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import { Button } from '../../Button';
import { ButtonLink } from '../../ButtonLink';
import { Container } from '../../Container';
import { Flex } from '../../Flex';
Expand Down Expand Up @@ -34,9 +35,9 @@ const HeaderDefault = () => {
</Navigation>
<Navigation marginLeft="auto" aria-label="Secondary Navigation">
<NavigationItem>
<ButtonLink href="#" color="tertiary" isSymmetrical>
<Button color="tertiary" isSymmetrical>
<Icon name="search" />
</ButtonLink>
</Button>
</NavigationItem>
<NavigationItem>
<ButtonLink href="#" color="secondary">
Expand Down
2 changes: 1 addition & 1 deletion packages/web-react/src/components/UNSTABLE_Header/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

export { default as UNSTABLE_Header } from './UNSTABLE_Header';
export { default as UNSTABLE_HeaderLogo } from './UNSTABLE_HeaderLogo';
export * as useUnstableHeaderStyleProps from './useHeaderStyleProps';
export * as useUnstableHeaderStyleProps from './useUnstableHeaderStyleProps';
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface HeaderStyles<T> {
props: T;
}

export const useHeaderStyleProps = (props: SpiritHeaderProps): HeaderStyles<SpiritHeaderProps> => {
export const useUnstableHeaderStyleProps = (props: SpiritHeaderProps): HeaderStyles<SpiritHeaderProps> => {
const headerClass = useClassNamePrefix('UNSTABLE_Header');
const headerLogoClass = useClassNamePrefix('UNSTABLE_HeaderLogo');

Expand Down

0 comments on commit 1500a68

Please sign in to comment.