Skip to content

Commit

Permalink
Merge pull request #12 from Teradata/fix/storybook-source-code
Browse files Browse the repository at this point in the history
fix(storybook): upgrade storybook and fix the source code issue
  • Loading branch information
owilliams320 committed Jun 14, 2024
2 parents 0f0e82b + f45d84e commit e333ac5
Show file tree
Hide file tree
Showing 24 changed files with 12,047 additions and 12,600 deletions.
31 changes: 31 additions & 0 deletions libs/react-components/.storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import type { StorybookConfig } from '@storybook/react-vite';
import { resolve } from 'path';
import { terser } from 'rollup-plugin-terser';

const config: StorybookConfig = {
stories: ['../src/lib/**/*.stories.@(js|jsx|ts|tsx|mdx)'],

addons: [
'@storybook/addon-essentials',
'@storybook/addon-interactions',
'@storybook/addon-a11y',
'@chromatic-com/storybook',
],

framework: {
name: '@storybook/react-vite',
options: {
Expand All @@ -16,6 +20,33 @@ const config: StorybookConfig = {
},
},
},

viteFinal: async (config, { configType }) => {
// Custom Vite configurations can be added here
if (configType === 'PRODUCTION') {
config?.plugins?.push(
terser({
compress: {
// Disable name mangling
keep_classnames: true,
keep_fnames: true,
},
mangle: {
keep_classnames: true,
keep_fnames: true,
},
})
);
}

return config;
},

docs: {},

typescript: {
reactDocgen: 'react-docgen-typescript',
},
};

export default config;
Expand Down
2 changes: 2 additions & 0 deletions libs/react-components/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const preview: Preview = {
},
},
},

tags: ['autodocs']
};

export default preview;
2 changes: 2 additions & 0 deletions libs/react-components/src/lib/components/Banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ const Banner: React.FC<BannerProps> = ({
);
};

Banner.displayName = 'Banner';

export default Banner;
6 changes: 5 additions & 1 deletion libs/react-components/src/lib/components/Blackout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ interface BlackoutProps {
const Blackout: React.FC<BlackoutProps> = ({ active = false, className }) => {
return (
<div
className={`${styles.pageBlackout} ${active ? styles.show : ''} ${className}`}
className={`${styles.pageBlackout} ${
active ? styles.show : ''
} ${className}`}
></div>
);
};

Blackout.displayName = 'Blackout';

export default Blackout;
2 changes: 2 additions & 0 deletions libs/react-components/src/lib/components/Chip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ const Chip: React.FC<ChipProps> = ({
);
};

Chip.displayName = 'Chip';

export default Chip;
2 changes: 2 additions & 0 deletions libs/react-components/src/lib/components/ChipSet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ const ChipSet: React.FC<ChipSetProps> = ({
);
};

ChipSet.displayName = 'ChipSet';

export default ChipSet;
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ const CodeSnippet: React.FC<CodeSnippetProps> = (props) => {
);
};

CodeSnippet.displayName = 'CodeSnippet';

export default CodeSnippet;
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@

.dropdownMenu {
margin-top: 5px;
padding: 0;
list-style: none;
background-color: transparent;
padding: 0 2.5rem;
padding: 0 1.5rem;
}

.dropdownMenuItem {
Expand Down
2 changes: 2 additions & 0 deletions libs/react-components/src/lib/components/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,6 @@ const Footer: React.FC<FooterProps> = ({
);
};

Footer.displayName = 'Footer';

export default Footer;
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@
var(--td-web-primary-navy),
var(--td-web-primary-navy)
);
background-image: webkit-linear-gradient(
var(--td-web-primary-navy),
var(--td-web-primary-navy)
);
background-position: 0 100%;
background-repeat: no-repeat;
background-size: 0 1px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react';

import Header from './index';
import Icon from '../Icon';
import Button from '../Button';

const meta = {
title: 'Components/Header',
Expand Down Expand Up @@ -86,7 +87,10 @@ const meta = {
),
type: 'search',
},
{ actionElement: <Icon className="fa fa-home" />, type: 'button' },
{
actionElement: <Button icon="fa fa-home" label="Start free demo" />,
type: 'button',
},
],
},
} satisfies Meta<typeof Header>;
Expand Down
35 changes: 23 additions & 12 deletions libs/react-components/src/lib/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,16 @@ const Header: React.FC<HeaderProps> = ({
secondaryMenu?.menuElement ? { paddingTop: '6.5rem' } : {}
}
>
<div>
<div className={styles.sidenavHeader}>
<h3>{secondaryMenu?.title}</h3>
<img
src={closeIcon}
onClick={handleDocsIconClick}
alt="Docs Menu"
/>
</div>
<div className={styles.sidenavContent}>
{secondaryMenu?.menuElement}
</div>
<div className={styles.sidenavHeader}>
<h3>{secondaryMenu?.title}</h3>
<img
src={closeIcon}
onClick={handleDocsIconClick}
alt="Docs Menu"
/>
</div>
<div className={styles.sidenavContent}>
{secondaryMenu?.menuElement}
</div>
</Sidenav>
</aside>
Expand All @@ -290,6 +288,17 @@ const Header: React.FC<HeaderProps> = ({
</div>

<footer>
<ul
className={`${styles.headerNavActions} ${styles.headerNavElement} ${styles.headerNavMobileActions}`}
>
{headerActions &&
headerActions.map(
(action, index) =>
action.type === 'button' && (
<li key={index}>{action.actionElement}</li>
)
)}
</ul>
<div className={styles.headerNavMobileFooter}>
<ul>
<li>
Expand Down Expand Up @@ -322,4 +331,6 @@ const Header: React.FC<HeaderProps> = ({
);
};

Header.displayName = 'Header';

export default Header;
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ body {

.headerNavMobileFooter ul {
margin: 1em 0;
padding: 0 2rem;
padding: 0 1.5rem;
display: flex;
align-items: center;
}
Expand All @@ -232,6 +232,18 @@ body {
font-weight: 700;
}

.headerNavMobileDropdownMenu {
overflow: auto;
}

.headerNavMobileActions {
padding: 0 1.5rem;

li {
margin: 1.5rem 0;
}
}

.headerNavMobileSecondaryMenu {
padding-top: 1.5rem;
padding-left: 2px;
Expand Down Expand Up @@ -265,6 +277,8 @@ body {

.sidenavContent {
padding: 1rem;
overflow: auto;
height: 100%;
}

@media screen and (min-width: 768px) and (max-width: 1024px) {
Expand Down
2 changes: 2 additions & 0 deletions libs/react-components/src/lib/components/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ const Icon: React.FC<React.HTMLProps<HTMLSpanElement>> = ({
return <i className={className} style={style}></i>;
};

Icon.displayName = 'Icon';

export default Icon;
2 changes: 2 additions & 0 deletions libs/react-components/src/lib/components/IconButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ const IconButton: React.FC<IconButtonProps> = ({
return <IconButtonComponent {...customProps}></IconButtonComponent>;
};

IconButton.displayName = 'IconButton';

export default IconButton;
2 changes: 2 additions & 0 deletions libs/react-components/src/lib/components/IconLink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,6 @@ const IconLink: React.FC<IconLinkProps> = ({
);
};

IconLink.displayName = 'IconLink';

export default IconLink;
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,6 @@ const LanguageDropdown: React.FC<LanguageDropdownProps> = ({
);
};

LanguageDropdown.displayName = 'LanguageDropdown';

export default LanguageDropdown;
2 changes: 2 additions & 0 deletions libs/react-components/src/lib/components/NavItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,6 @@ const NavItem: React.FC<NavItemProps> = ({
);
};

NavItem.displayName = 'NavItem';

export default NavItem;
6 changes: 5 additions & 1 deletion libs/react-components/src/lib/components/Sidenav/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ interface SidenavProps extends PropsWithChildren, HTMLProps<HTMLDivElement> {
const Sidenav: React.FC<SidenavProps> = ({ children, show, left, style }) => {
return (
<div
className={`${styles.sidenav} ${show ? styles.show : ''} ${left ? styles.left : styles.right}`}
className={`${styles.sidenav} ${show ? styles.show : ''} ${
left ? styles.left : styles.right
}`}
style={style}
>
{children}
</div>
);
};

Sidenav.displayName = 'Sidenav';

export default Sidenav;
3 changes: 3 additions & 0 deletions libs/react-components/src/lib/components/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,7 @@ const TabBar: React.FC<TabBarProps> = ({
);
};

Tab.displayName = 'Tab';
TabBar.displayName = 'TabBar';

export { Tab, TabBar };
2 changes: 2 additions & 0 deletions libs/react-components/src/lib/components/Typography/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ const Typography: React.FC<TypographyProps> = ({
);
};

Typography.displayName = 'Typography';

export default Typography;
4 changes: 3 additions & 1 deletion libs/react-components/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import NavItem, { NavListItem } from './components/NavItem';
import Chip from './components/Chip';
import ChipSet from './components/ChipSet';
import { Tab, TabBar } from './components/Tabs';
import Typography from './components/Typography';

export {
Banner,
Expand All @@ -37,7 +38,8 @@ export {
LanguageDropdown,
NavItem,
Tab,
TabBar
TabBar,
Typography,
};

export type {
Expand Down
Loading

0 comments on commit e333ac5

Please sign in to comment.