Skip to content

Commit

Permalink
Components: Simplify prop forwarding.
Browse files Browse the repository at this point in the history
  • Loading branch information
filiphsps committed Nov 17, 2023
1 parent 7b608b1 commit fba1544
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .changeset/fast-carrots-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@nordcom/nordstar-system': patch
---

Remove unused css module.
7 changes: 2 additions & 5 deletions packages/components/card/src/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ export type CardProps = {
as?: As;
};

const Card = forwardRef<'section', CardProps>((props, ref) => {
const { as, className } = props;

const Card = forwardRef<'section', CardProps>(({ as, className, ...props }, ref) => {
const Tag = as || 'section';
const classes = `${styles.container}${className ? ` ${className}` : ''}`;

// TODO: Figure out a better way to exclude props from being passed to the DOM element.
return <Tag ref={ref} {...{ ...props, as: undefined, className: undefined }} className={classes} />;
return <Tag ref={ref} {...props} className={classes} />;
});

Card.displayName = 'Nordstar.Card';
Expand Down
9 changes: 2 additions & 7 deletions packages/components/heading/src/heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@ export type HeadingProps = {
as?: As;
};

const Heading = forwardRef<'h1', HeadingProps>((props, ref) => {
const { as, level = 'h1', className } = props;

const Heading = forwardRef<'h1', HeadingProps>(({ as, level = 'h1', className, ...props }, ref) => {
const Tag = as || level;
const classes = `${styles.container} ${styles[level]}${className ? ` ${className}` : ''}`;

// TODO: Figure out a better way to exclude props from being passed to the DOM element.
return (
<Tag ref={ref} {...{ ...props, level: undefined, as: undefined, className: undefined }} className={classes} />
);
return <Tag ref={ref} {...props} className={classes} />;
});

Heading.displayName = 'Nordstar.Typography.Heading';
Expand Down
6 changes: 2 additions & 4 deletions packages/components/view/src/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ export type ViewProps = {
children?: ReactNode;
};

const View = forwardRef<'main', ViewProps>((props, ref) => {
const { className } = props;
const View = forwardRef<'main', ViewProps>(({ className, ...props }, ref) => {
const classes = `${styles.content}${className ? ` ${className}` : ''}`;

// TODO: Figure out a better way to exclude props from being passed to the DOM element.
return (
<div className={styles.container}>
<main ref={ref} {...{ ...props, className: undefined }} className={classes} />
<main ref={ref} {...props} className={classes} />
</div>
);
});
Expand Down
3 changes: 0 additions & 3 deletions packages/core/system/src/nordstar-provider.module.scss

This file was deleted.

3 changes: 1 addition & 2 deletions packages/core/system/src/nordstar-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { ReactNode } from 'react';
import styles from './nordstar-provider.module.scss';
import './styling.scss';

export type NordstarProviderProps = {
children: ReactNode;
};

export const NordstarProvider = ({ children }: NordstarProviderProps) => {
return <div className={styles.container}>{children}</div>;
return <>{children}</>;
};
8 changes: 6 additions & 2 deletions packages/storybook/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ const parameters: Preview['parameters'] = {
dark: {
...brand,
appBg: '#262626',
barBg: '#262626',
background: '#262626',
appContentBg: '#262626',
background: '#262626',
barBg: '#262626',
barSelectedColor: '#ed1e79',
colorPrimary: '#ed1e79',
inputBorderRadius: 0,
textColor: '#fefefe',
brandImage: 'https://nordcom.io/logo-light.svg'
}
}
Expand Down

1 comment on commit fba1544

@vercel
Copy link

@vercel vercel bot commented on fba1544 Nov 17, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nordstar – ./docs

nordstar-nordcom.vercel.app
nordstar-git-master-nordcom.vercel.app
nordstar.vercel.app
nordstar.nordcom.io

Please sign in to comment.