Skip to content

Commit

Permalink
Card: Add component stub to test tooling and workflows.
Browse files Browse the repository at this point in the history
While you might be able to use the component by directly importing it,
it will only wrap your content in a `section` html element and not
actually provide any styling or functionality. :^)
  • Loading branch information
filiphsps committed Nov 5, 2023
1 parent 678643c commit cc475d1
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .changeset/short-pears-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@nordcom/nordstar-card': patch
---

Add `<Card/>` component stub to test if the current release workflow is correctly setup.

While you should be able to actually use the component, it will only wrap your content in a `section` html element.
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
"editor.wordWrap": "off",
"workbench.editor.restoreViewState": false
},
"cSpell.words": ["Brandly", "Nordcom", "nordstar"],
"cSpell.words": ["Brandly", "Filiph", "Nordcom", "nordstar", "Sandström", "Siitam", "typecheck"],
"markdown.extension.list.indentationSize": "inherit",
"markdown.extension.toc.levels": "2..6",
"markdown.extension.toc.omittedFromToc": {
"CONTRIBUTING.md": ["## Table of Contents"]
},
"markdown.extension.toc.slugifyMode": "github"
"markdown.extension.toc.slugifyMode": "github",
"markdownlint.ignore": ["**/.changeset/**.md"]
}
22 changes: 22 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"typecheck": "turbo typecheck",
"lint": "concurrently --raw npm:lint:*",
"lint:docs": "eslint ./docs/**/*.{ts,tsx} --no-error-on-unmatched-pattern",
"lint:packages": "eslint ./packages/**/**/*.{ts,tsx}",
"lint:packages": "eslint ./packages/**/src/**/*.{ts,tsx}",
"test": "concurrently --raw npm:test:*",
"test:docs": "",
"test:packages": "vitest run --coverage --passWithNoTests",
Expand Down
9 changes: 9 additions & 0 deletions packages/components/card/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @nordcom/nordstar-card

The description of this component: `<Card/>` is a consistent looking container for content.

## Installation

```sh
npm install @nordcom/nordstar-card
```
68 changes: 68 additions & 0 deletions packages/components/card/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "@nordcom/nordstar-card",
"version": "0.0.1",
"description": "&#x60;&lt;Card/&gt;&#x60; is a consistent looking container for content.",
"main": "src/index.ts",
"sideEffects": false,
"engines": {
"npm": ">=8",
"node": ">=18 <=21"
},
"scripts": {
"build": "tsup src --dts",
"build:fast": "tsup src",
"dev": "npm run build:fast -- --watch",
"clean": "rimraf dist .turbo",
"typecheck": "tsc --noEmit",
"prepack": "clean-package",
"postpack": "clean-package restore"
},
"keywords": [
"nordstar",
"nordcom",
"component",
"react",
"card",
"nordstar-card"
],
"author": {
"name": "Nordcom Group Inc.",
"email": "[email protected]",
"url": "https://nordcom.io/"
},
"contributors": [
{
"name": "Filiph Siitam Sandström",
"email": "[email protected]",
"url": "https://github.com/filiphsps/"
}
],
"repository": {
"type": "git",
"url": "git+https://github.com/NordcomInc/nordstar.git",
"directory": "packages/components/card"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/NordcomInc/nordstar/issues"
},
"homepage": "https://nordstar.nordcom.io/docs/components/card/",
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"dependencies": {
"@nordcom/nordstar": "*"
},
"peerDependencies": {
"react": ">=18"
},
"devDependencies": {
"clean-package": "2.2.0",
"react": "18.2.0"
},
"clean-package": "../../../clean-package.config.json"
}
16 changes: 16 additions & 0 deletions packages/components/card/src/card.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { Meta } from '@storybook/react';
import type { CardProps } from '../src';
import { Card } from '../src';

export default {
title: 'Components/Card',
component: Card,
argTypes: {}
} as Meta<typeof Card>;

const Template = (args: CardProps) => <Card {...args} />;

export const Default = {
render: Template,
args: {}
};
14 changes: 14 additions & 0 deletions packages/components/card/src/card.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { describe, expect, it } from 'vitest';

import { Card } from '../src';
import { render } from '@testing-library/react';

describe('components', () => {
describe('Card', () => {
it('should render correctly', () => {
const wrapper = render(<Card />);

expect(() => wrapper.unmount()).not.toThrow();
});
});
});
13 changes: 13 additions & 0 deletions packages/components/card/src/card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { HTMLProps, ReactNode } from 'react';

export type CardProps = {
children?: ReactNode;
} & HTMLProps<HTMLDivElement>;

const Card = (props: CardProps) => {
const { children } = props;

return <section {...props}>{children}</section>;
};

export default Card;
5 changes: 5 additions & 0 deletions packages/components/card/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Card from './card';

export type { CardProps } from './card';

export { Card };
8 changes: 8 additions & 0 deletions packages/components/card/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/tsconfig.json",
"extends": "../../../tsconfig.json",
"compilerOptions": {
"baseUrl": "."
},
"include": ["src", "index.ts"]
}
8 changes: 8 additions & 0 deletions packages/components/card/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'tsup';

export default defineConfig({
clean: true,
target: 'esnext',
entry: ['src/index.ts', '!src/scripts'],
format: ['cjs', 'esm']
});

0 comments on commit cc475d1

Please sign in to comment.