Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/2 multi packages #3

Merged
merged 31 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
4968cc7
file reorg for multiple package publishing
pospi Aug 29, 2023
91da563
ignore Storybook build files
pospi Aug 29, 2023
d314428
refactor/split module metadata files for multiple component packages
pospi Aug 29, 2023
4bdfec3
reinitialise Storybook from latest config
pospi Aug 29, 2023
5740ce0
fix package wildcard exports
pospi Aug 29, 2023
d5eb661
update lockfile
pospi Aug 29, 2023
e8b55b3
fix compilation error in type import under TS5.x
pospi Aug 29, 2023
ca74eed
fix invalid Storybook (root-level) Vite config
pospi Aug 29, 2023
70ddbd3
remove unnecessary root-level workspace imports
pospi Aug 29, 2023
1eebbc0
fix DialogType export
pospi Aug 31, 2023
1382f69
remove toplevel deps not needed directly in Storybook env
pospi Aug 31, 2023
b1f6b13
add font resources from https://github.com/neighbour-hoods/css-styles
pospi Aug 31, 2023
ae81c8c
enable static asset dir, reference fonts in preview styles from serve…
pospi Aug 31, 2023
96794a1
fix CustomElement registration bugs
pospi Aug 31, 2023
8906045
update Storybook, add ScopedCustomElementRegistry polyfill dependency
pospi Aug 31, 2023
c2bc8dd
update lockfile
pospi Aug 31, 2023
4c16506
fix font token
nick-stebbings Sep 1, 2023
b495dd1
fix card/post-card menus
nick-stebbings Sep 1, 2023
a756dd1
update profile components and order them
nick-stebbings Sep 1, 2023
51d5ed1
change deprecated background token
nick-stebbings Sep 1, 2023
7084f21
add default backgrounds
nick-stebbings Sep 1, 2023
f7e9d36
match backgrounds to latest design standards
nick-stebbings Sep 1, 2023
51ffd9e
bg, font, button style updates
nick-stebbings Sep 1, 2023
359ba06
change menu to button-group
nick-stebbings Sep 1, 2023
6f6eaa8
identicon bg change
nick-stebbings Sep 1, 2023
96ceb49
remove erroneous style tokens
nick-stebbings Sep 1, 2023
6e56bb1
install styles package
nick-stebbings Sep 1, 2023
1780841
update card bg token
nick-stebbings Sep 1, 2023
192f233
remove fonts and import from styles package
nick-stebbings Sep 1, 2023
ac5b1a5
change profile card bg
nick-stebbings Sep 2, 2023
4c30adc
change cross dependency loading
nick-stebbings Sep 2, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ lerna-debug.log*
node_modules
dist
dist-ssr
storybook-static
types
*.local

Expand Down
18 changes: 12 additions & 6 deletions .storybook/main.cjs → .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
import type { StorybookConfig } from "@storybook/web-components-vite";

const config: StorybookConfig = {
stories: ['../**/src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
framework: '@storybook/web-components',
core: {
builder: 'storybook-builder-vite',
framework: {
name: "@storybook/web-components-vite",
options: {},
},
docs: {
autodocs: "tag",
},
staticDirs: ['../public'],
async viteFinal(config, { configType }) {
Expand All @@ -17,4 +22,5 @@ module.exports = {
// return the customized config
return config
},
}
};
export default config;
36 changes: 2 additions & 34 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -1,37 +1,5 @@
<script>
window.global = window;
window.global = window;
</script>
<style>
@font-face {
font-family: 'Manrope';
font-weight: 400;
font-style: normal;
font-display: auto;
src: local('Manrope'), url('Manrope-Regular.ttf') format('truetype');
}
@font-face {
font-family: 'ManropeBold';
font-weight: 700;
font-style: normal;
font-display: auto;
src: local('Manrope'), url('Manrope-Bold.ttf') format('truetype');
}
@font-face {
font-family: 'Work Sans';
font-style: normal;
font-display: auto;
src: local('Work Sans'), url('WorkSans.ttf') format('truetype');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-display: auto;
src: local('Open Sans'), url('OpenSans.ttf') format('truetype');
}
:host {
--nh-menu-subtitle: #A89CB0;
--nh-theme-bg-neutral: #433A4A;
--nh-font-families-menu: "Work Sans", "Open Sans";
}
</style>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/[email protected]/cdn/themes/dark.css" />
9 changes: 0 additions & 9 deletions .storybook/preview.cjs

This file was deleted.

40 changes: 40 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// polyfills
import '@webcomponents/scoped-custom-element-registry'

import type { Preview } from "@storybook/web-components";

import { b64fonts } from '@neighbourhoods/design-system-styles';

const preview: Preview = {
parameters: {
backgrounds: {
// For where to use each of these, see:
// https://github.com/orgs/neighbour-hoods/projects/1/views/1?filterQuery=depth&pane=issue&itemId=33428362

default: 'canvas',
values: [
{
name: 'backdrop',
value: '#0c0a0d',
},
{
name: 'canvas',
value: '#18151b',
},
{
name: 'surface',
value: '#251f28',
},
],
},
actions: { argTypesRegex: "^on[A-Z].*" },
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
},
};

export default preview;
62 changes: 22 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,41 @@
# Neighbourhoods design system components (and Storybook) UNSTABLE
# Neighbourhoods UI Component Storybook [UNSTABLE]

Currently this package exports these components, all of which are under development but act as a good starting point for building Neighbourhoods UI:
Metarepo for various CustomElement component libraries used in Neighbourhoods Applets and within the [Neighbourhoods Launcher](https://github.com/neighbour-hoods/nh-launcher/):

## Base Components
(Comprising of the LitElement ancestor components from the `neighbourhoods-design-system-components` package - now deprecated). Use these as a base if you just want to inherit styles:

`NHComponent` - Just the NH design token CSS variables

`NHComponentShoelace` - In future we will add some Shoelace variable overrides so use this to include them too

## NH Components
`NHButton`

`NHButtonGroup`

`NHCard`

`NHPostCard`

`NHCardList`

`NHTabButton`

`NHPagination`

`NHPageHeaderCard`

`NHAssessmentWidget`

`NHMenu` -- currently same as NHButtonGroup

## NH Shoelace Components (use `sl-` webcomponents internally)
`NHDialog`

`NHAlert`

`NHCreatePost`
- The [Design System Components](src/design-system) implementing abstract and harmoniously coordinated UI controls which operate well together.
- [Developer Utility Components](src/dev-util) useful in Applet development & testing.

## Install

Ensure you have the PNPM package manager installed first with `npm i -g pnpm`.

```bash
pnpm install
```

## Storybook

```bash
npm run storybook
pnpm run storybook
```

## Build

```bash
npm run build
pnpm run build
```

Original repo forked from Leon Radley (thanks!)
https://leon.id/articles/web-components/2022-02-vite-lit-storybook
## Publish

- Ensure all packages requiring publication have their `version` field in `package.json` updated to reflect the next version to be published.
- Ensure a successful `pnpm run build` completes after the version updates are made.
- Run `pnpm -r publish --access public` from the root directory to publish all packages with updated versions.

## Credits

Original repo forked from Leon Radley (thanks!)
https://leon.id/articles/web-components/2022-02-vite-lit-storybook

## License

Apache 2.0
41 changes: 41 additions & 0 deletions design-system/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Neighbourhoods design system components

Currently this package exports these components, all of which are under development but act as a good starting point for building Neighbourhoods UI:

## Base Components

(Comprising of the LitElement ancestor components from the `neighbourhoods-design-system-components` package - now deprecated). Use these as a base if you just want to inherit styles:

`NHComponent` - Just the NH design token CSS variables

`NHComponentShoelace` - In future we will add some Shoelace variable overrides so use this to include them too

## NH Components

`NHButton`

`NHButtonGroup`

`NHCard`

`NHPostCard`

`NHCardList`

`NHTabButton`

`NHPagination`

`NHPageHeaderCard`

`NHAssessmentWidget`

`NHMenu` -- currently same as NHButtonGroup

## NH Shoelace Components (use `sl-` webcomponents internally)

`NHDialog`

`NHAlert`

`NHCreatePost`
38 changes: 38 additions & 0 deletions design-system/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@neighbourhoods/design-system-components",
"version": "0.0.4",
"type": "module",
"files": [
"dist"
],
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.umd.js"
}
},
"./*": {
"types": "./dist/",
"import": "./dist/"
}
},
"types": "./dist/index.d.ts",
"main": "./dist/index.umd.js",
"module": "./dist/index.js",
"scripts": {
"build": "vite build; tsc -p ./tsconfig.json"
},
"devDependencies": {
"tslib": "^2.3.1",
"typescript": "^4.5.5",
"vite": "^4.4.9"
},
"dependencies": {
"@lit-labs/scoped-registry-mixin": "^1.0.1",
"@neighbourhoods/design-system-styles": "^0.0.3",
"@shoelace-style/shoelace": "^2.8.0",
"lit": "^2.2.0"
}
}
19 changes: 19 additions & 0 deletions design-system/src/_shared_customElements.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Workaround import for cross-dependencies between stories.
*
* CustomElement registration for components shared between stories needs to be done exactly once.
*/

import NHButton from "./button";
import NHCard from "./card";
import NHPageHeaderCard from './page-header-card'
import NHTabButton from "./tab-button";

let loaded = false
if (!loaded) {
pospi marked this conversation as resolved.
Show resolved Hide resolved
customElements.define('nh-button', NHButton)
customElements.define('nh-card', NHCard)
customElements.define('nh-tab-button', NHTabButton)
customElements.define('nh-page-header-card', NHPageHeaderCard)
loaded = true
}
4 changes: 2 additions & 2 deletions src/alert.ts → design-system/src/alert.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { css, CSSResult, html } from 'lit';
import {property } from 'lit/decorators.js';
import { NHComponentShoelace } from './ancestors/base';
import { SlAlert } from '@scoped-elements/shoelace';
import SlAlert from '@shoelace-style/shoelace/dist/components/alert/alert.js';

export type AlertType = 'danger' | 'warning' | 'neutral' | 'success' | 'primary';

export class NHAlert extends NHComponentShoelace {
export default class NHAlert extends NHComponentShoelace {
@property()
open: boolean = true;
@property()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { b64images } from '@neighbourhoods/design-system-styles';
import './assessment-widget';
import { html } from 'lit';
import type { Meta, StoryObj } from '@storybook/web-components';
import NHAssessmentWidget from './assessment-widget';

customElements.define('nh-assessment-widget', NHAssessmentWidget)

interface AssessmentWidgetProps {
name: string;
Expand All @@ -11,13 +13,15 @@ interface AssessmentWidgetProps {

const meta: Meta<AssessmentWidgetProps> = {
title: 'NHComponent/AssessmentWidget',
component: 'nh-card',
component: 'nh-assessment-widget',
argTypes: {
name: { control: 'text' },
iconImg: { control: 'text' },
iconAlt: { control: 'text' },
},
render: (args) => html`<nh-assessment-widget .name=${args.name} .iconAlt=${args.iconAlt} .iconImg=${args.iconImg}></nh-assessment-widget>`,
parameters: {
backgrounds: { default: 'surface' },
},
};

export default meta;
Expand Down Expand Up @@ -45,4 +49,4 @@ export const Chili: Story = {
iconAlt: 'hot!',
iconImg: b64images.icons.chili
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {property, query, queryAll } from "lit/decorators.js";
import { classMap } from "lit/directives/class-map.js";
import { NHComponentShoelace } from "./ancestors/base";

export class NHAssessmentWidget extends NHComponentShoelace {
export default class NHAssessmentWidget extends NHComponentShoelace {
@property()
name!: string;
@property()
Expand Down Expand Up @@ -121,7 +121,7 @@ export class NHAssessmentWidget extends NHComponentShoelace {
}

.assessment-icon-container {
background-color: var(--nh-theme-bg-muted);
background-color: var(--nh-theme-bg-detail);
border-radius: var(--border-r-tiny);
width: 40px;
height: 40px;
Expand Down
Loading