Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const getStories = () => {
"./../../packages/design-system-react-native/src/components/ButtonBase/ButtonBase.stories.tsx": require("../../../packages/design-system-react-native/src/components/ButtonBase/ButtonBase.stories.tsx"),
"./../../packages/design-system-react-native/src/components/ButtonIcon/ButtonIcon.stories.tsx": require("../../../packages/design-system-react-native/src/components/ButtonIcon/ButtonIcon.stories.tsx"),
"./../../packages/design-system-react-native/src/components/Checkbox/Checkbox.stories.tsx": require("../../../packages/design-system-react-native/src/components/Checkbox/Checkbox.stories.tsx"),
"./../../packages/design-system-react-native/src/components/HeaderBase/HeaderBase.stories.tsx": require("../../../packages/design-system-react-native/src/components/HeaderBase/HeaderBase.stories.tsx"),
"./../../packages/design-system-react-native/src/components/Icon/Icon.stories.tsx": require("../../../packages/design-system-react-native/src/components/Icon/Icon.stories.tsx"),
"./../../packages/design-system-react-native/src/components/temp-components/Blockies/Blockies.stories.tsx": require("../../../packages/design-system-react-native/src/components/temp-components/Blockies/Blockies.stories.tsx"),
"./../../packages/design-system-react-native/src/components/temp-components/ButtonAnimated/ButtonAnimated.stories.tsx": require("../../../packages/design-system-react-native/src/components/temp-components/ButtonAnimated/ButtonAnimated.stories.tsx"),
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system-react-native/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = merge(baseConfig, {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
},
transformIgnorePatterns: [
'node_modules/(?!react-native|@react-native|react-native-reanimated|@react-navigation)',
'node_modules/(?!react-native|@react-native|react-native-reanimated|@react-navigation|react-native-safe-area-context)',
],
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],
moduleNameMapper: {
Expand Down
5 changes: 5 additions & 0 deletions packages/design-system-react-native/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
jest.mock(
'react-native-safe-area-context',
() => require('react-native-safe-area-context/jest/mock').default,
);

jest.mock('react-native-svg', () => {
const React = require('react');
const { View } = require('react-native');
Expand Down
2 changes: 1 addition & 1 deletion packages/design-system-react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@metamask/utils": "^11.10.0",
"@storybook/react-native": "6.5",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/react-native": "^12.8.1",
"@testing-library/react-native": "^13.2.0",
"@ts-bridge/cli": "^0.6.3",
"@types/babel__preset-env": "^7",
"@types/fast-text-encoding": "^1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// External dependencies.
import { TextVariant } from '../Text';

/**
* Text variant used for the header title when children is a string.
*/
export const HEADERBASE_TITLE_TEXT_VARIANT = TextVariant.HeadingSm;

/**
* Default test IDs for HeaderBase component.
*/
export const HEADERBASE_TEST_ID = 'header';
export const HEADERBASE_TITLE_TEST_ID = 'header-title';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove image as it can become out dated

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import type { Meta, StoryObj } from '@storybook/react-native';
import React from 'react';

import { Box } from '../Box';
import { ButtonIcon, ButtonIconSize } from '../ButtonIcon';
import { IconName } from '../Icon';
import { Text, TextVariant } from '../Text';

import HeaderBase from './HeaderBase';
import type { HeaderBaseProps } from './HeaderBase.types';

const meta: Meta<HeaderBaseProps> = {
title: 'Components/HeaderBase',
component: HeaderBase,
argTypes: {
children: {
control: 'text',
},
twClassName: {
control: 'text',
},
includesTopInset: {
control: 'boolean',
},
},
};

export default meta;

type Story = StoryObj<HeaderBaseProps>;

const noop = (): void => undefined;

export const Default: Story = {
args: {
children: 'Header Title',
},
render: (args) => <HeaderBase {...args} />,
};

export const TwClassName: Story = {
render: () => (
<HeaderBase twClassName="bg-info-default px-4">
Header with Custom Styles
</HeaderBase>
),
};
Comment on lines +41 to +47
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't think we need this story for the twClassName prop just let the readme template explain it. If this was created by the cursor rule, let's update the rule to exclude these props that are taken care of by readme


export const StartButtonIconProps: Story = {
render: () => (
<HeaderBase
startButtonIconProps={{
iconName: IconName.ArrowLeft,
onPress: noop,
}}
>
With Start Button
</HeaderBase>
),
};

export const EndButtonIconProps: Story = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

maybe we can be a bit more selective on stories and improve the cursor rule here to exclude prop object, twClassName and style props

render: () => (
<HeaderBase
endButtonIconProps={[
{
iconName: IconName.Close,
onPress: noop,
},
]}
>
With End Button
</HeaderBase>
),
};

export const MultipleEndButtonIconProps: Story = {
render: () => (
<HeaderBase
endButtonIconProps={[
{
iconName: IconName.Close,
onPress: noop,
},
{
iconName: IconName.Search,
onPress: noop,
},
{
iconName: IconName.Setting,
onPress: noop,
},
]}
>
Multiple End Buttons
</HeaderBase>
),
};

export const StartAccessory: Story = {
render: () => (
<HeaderBase
startAccessory={
<ButtonIcon
iconName={IconName.ArrowLeft}
size={ButtonIconSize.Md}
onPress={noop}
/>
}
>
With Start Accessory
</HeaderBase>
),
};

export const EndAccessory: Story = {
render: () => (
<HeaderBase
endAccessory={
<ButtonIcon
iconName={IconName.Close}
size={ButtonIconSize.Md}
onPress={noop}
/>
}
>
With End Accessory
</HeaderBase>
),
};

export const BothAccessories: Story = {
render: () => (
<HeaderBase
startAccessory={
<ButtonIcon
iconName={IconName.ArrowLeft}
size={ButtonIconSize.Md}
onPress={noop}
/>
}
endAccessory={
<ButtonIcon
iconName={IconName.Close}
size={ButtonIconSize.Md}
onPress={noop}
/>
}
>
Both Accessories
</HeaderBase>
),
};

export const Children: Story = {
render: () => (
<HeaderBase
startButtonIconProps={{
iconName: IconName.ArrowLeft,
onPress: noop,
}}
>
<Box twClassName="items-center">
<Text variant={TextVariant.HeadingSm}>Custom Title</Text>
<Text variant={TextVariant.BodySm}>Subtitle text</Text>
</Box>
</HeaderBase>
),
};
Loading
Loading