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

refactor: rename lyne-components into lyne-elements and create lyne-elements-experimental #2675

Merged
merged 21 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
abfcea9
refactor: create '@lyne-esta/elements-experimental' library
TomMenga May 14, 2024
ba32805
refactor(timetable-duration): move to '@lyne-esta/elements-experimen…
TomMenga May 14, 2024
323898e
refactor(timetable, journey, pearl, chain): move to '@lyne-esta/elem…
TomMenga May 14, 2024
8792d49
refactor(custom-elements-manifest): split manifest for each library
TomMenga May 14, 2024
fdb24a9
refactor: create '@sbb-esta/lyne-react-experimental' library
TomMenga May 20, 2024
86ec5f3
refactor: rename '@sbb-esta/lyne-components' => '@sbb-esta/lyne-eleme…
TomMenga May 20, 2024
fd5bcb6
refactor: generate docs from multiple manifests
TomMenga May 20, 2024
8300404
chore: post rebase fixes
TomMenga May 20, 2024
c387818
chore: fix lint
TomMenga May 21, 2024
92ce049
chore: integrity
TomMenga May 21, 2024
146c2dc
refactor: fix imports in visual-regression-app
TomMenga May 22, 2024
3c89faf
Merge branch 'refs/heads/main' into refactor/split-packages
TomMenga May 23, 2024
80bf727
test(image): fix test
TomMenga May 23, 2024
1052f90
ci(release): adapt release to the new libraries
TomMenga May 23, 2024
e1d37b2
Merge remote-tracking branch 'refs/remotes/origin/main' into refactor…
TomMenga May 27, 2024
0dc56c6
chore(codecov): update ignore path
TomMenga May 27, 2024
cde2798
fix: review feedbacks
TomMenga May 28, 2024
6a4246e
Merge branch 'refs/heads/main' into refactor/split-packages
TomMenga May 28, 2024
288d7a6
refactor(react-experimental): create a different folder for the package
TomMenga May 29, 2024
c2e4c28
docs: update readme and getting started withe experimental package info
TomMenga May 29, 2024
5fe368a
Merge branch 'refs/heads/main' into refactor/split-packages
TomMenga May 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
exitZeroOnChanges: true
zip: true
onlyChanged: true
externals: '**/components/core/styles/**/*.scss'
externals: '**/elements/core/styles/**/*.scss'

visual-regression:
runs-on: ubuntu-latest
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,22 @@ jobs:
- name: 'Release: Determine npm tag'
id: npm_tag
run: echo "npm_tag=$([[ "$VERSION" == *"-"* ]] && echo "next" || echo "latest")" >> $GITHUB_OUTPUT
- name: 'Release: Publish @sbb-esta/lyne-components'
run: yarn publish dist/components --tag ${{ steps.npm_tag.outputs.npm_tag }}
- name: 'Release: Publish @sbb-esta/lyne-elements'
run: yarn publish dist/elements --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 'Release: Publish @sbb-esta/lyne-components-react'
- name: 'Release: Publish @sbb-esta/lyne-elements-experimental'
run: yarn publish dist/elements-experimental --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 'Release: Publish @sbb-esta/lyne-react'
run: yarn publish dist/react --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: 'Release: Publish @sbb-esta/lyne-react-experimental'
run: yarn publish dist/react-experimental --tag ${{ steps.npm_tag.outputs.npm_tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Remove files with forbidden extensions
run: node ./scripts/clean-storybook-files.cjs
Expand Down
4 changes: 2 additions & 2 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { html } from 'lit';

import { withBackgroundDecorator } from '../src/storybook/testing/with-background-decorator.js';

import '../src/components/core/styles/standard-theme.scss';
import '../src/elements/core/styles/standard-theme.scss';

const getViewportName = (key: string): string =>
key.replace(/(^SbbBreakpoint|Min$)/g, '').toLowerCase();
Expand Down Expand Up @@ -66,7 +66,7 @@ const parameters: Parameters = {
storySort: {
// Story section order.
// https://storybook.js.org/docs/react/writing-stories/naming-components-and-hierarchy#sorting-stories
order: ['introduction', 'pages', 'components', 'styles', 'timetable', 'internals'],
order: ['introduction', 'pages', 'elements', 'experimental', 'styles', 'internals'],
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
comment: false
ignore:
- 'src/components/core/testing/**/*'
- 'src/elements/core/testing/**/*'
4 changes: 2 additions & 2 deletions docs/CODING_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ For this purpose we provide the `hostContext(selector: string, base: Element): E
function, which returns the closest match or null, if no match is found.

This can be used in the `connectedCallback()` (see
[Lit Lifecycle](https://lit.dev/docs/components/lifecycle/)) method of a component,
[Lit Lifecycle](https://lit.dev/docs/elements/lifecycle/)) method of a component,
TomMenga marked this conversation as resolved.
Show resolved Hide resolved
which should minimize the performance impact of this detection.

**Usages of this functionality should be carefully considered. If a component has too many variants
Expand Down Expand Up @@ -507,7 +507,7 @@ Also define CSS variables in :host.
#### Use/Check existing CSS variables and SCSS mixins/functions

The `@sbb-esta/lyne-design-tokens` package provides global design tokens/CSS variables,
which are used/configured in our code base (see `src/components/core/styles/core/variables.scss`).
which are used/configured in our code base (see `src/elements/core/styles/core/variables.scss`).

Use these variables instead of the original ones and only define new variables for components.
If a global variable is missing, create an issue or pull request in
Expand Down
6 changes: 3 additions & 3 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ Providing the following information will increase the
chances of your issue being dealt with quickly:

- **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps
- **@sbb-esta/lyne-components Version** - which version is affected
- **@sbb-esta/lyne-elements Version** - which version is affected
- **Motivation for or Use Case** - explain what are you trying to do and why the current behavior
is a bug for you
- **Browsers and Operating System** - is this a problem with all browsers?
- **Reproduce the Error** - provide a live example (using StackBlitz or similar) or an unambiguous set of steps
- **Screenshots** - Due to the visual nature of @sbb-esta/lyne-components, screenshots can help the team
- **Screenshots** - Due to the visual nature of @sbb-esta/lyne-elements, screenshots can help the team
triage issues far more quickly than a text description.
- **Related Issues** - has a similar issue been reported before?
- **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
Expand Down Expand Up @@ -172,7 +172,7 @@ The rest of the commit message is then used for this.

This project publishes the following package:

- @sbb-esta/lyne-components
- @sbb-esta/lyne-elements
TomMenga marked this conversation as resolved.
Show resolved Hide resolved

### Styling

Expand Down
10 changes: 5 additions & 5 deletions docs/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ Run `yarn lint --fix` to fix any automatically fixable lint issues and report th

## Outputs

| Folder | Explanation |
| ----------------- | ------------------------------------- |
| ./dist/components | main output target for web-components |
| ./dist/react | output target for the react library |
| ./dist/storybook | rendered static storybook site |
| Folder | Explanation |
| ---------------- | ------------------------------------- |
| ./dist/elements | main output target for web-components |
| ./dist/react | output target for the react library |
| ./dist/storybook | rendered static storybook site |

## Running tests

Expand Down
58 changes: 29 additions & 29 deletions docs/GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ Select your technology to get started.
<details>
<summary>Plain Javascript</summary>

1. Install the `@sbb-esta/lyne-components` package:
1. Install the `@sbb-esta/lyne-elements` package:

```sh
npm install --save @sbb-esta/lyne-components
npm install --save @sbb-esta/lyne-elements
```

or, if using yarn:

```sh
yarn add @sbb-esta/lyne-components
yarn add @sbb-esta/lyne-elements
```

2. Including global styles is strongly recommended to apply all SBB styles to your application.
See [styles](#styles) section if you prefer more granularity on what to import.

```css
@import 'node_modules/@sbb-esta/lyne-components/standard-theme.css';
@import 'node_modules/@sbb-esta/lyne-elements/standard-theme.css';
```

3. Import the desired element and add it to globalThis:

```ts
import { SbbButtonElement } from '@sbb-esta/lyne-components/button.js';
import { SbbButtonElement } from '@sbb-esta/lyne-elements/button.js';

globalThis.SbbButtonElement = SbbButtonElement;
```
Expand All @@ -43,24 +43,24 @@ Select your technology to get started.
> However, it's already possible to use Lyne Components in Angular.

1. Install Angular CLI, see [Angular CLI documentation](https://cli.angular.io/)
2. Install the `@sbb-esta/lyne-components` package:
2. Install the `@sbb-esta/lyne-elements` package:

```sh
npm install --save @sbb-esta/lyne-components
npm install --save @sbb-esta/lyne-elements
```

or, if using yarn:

```sh
yarn add @sbb-esta/lyne-components
yarn add @sbb-esta/lyne-elements
```

3. Including global styles is strongly recommended to apply all SBB styles to your application.
See [styles](#styles) section if you prefer more granularity on what to import.
Importing stylsheets is doable by editing the `styles.(s)css`:

```css
@import 'node_modules/@sbb-esta/lyne-components/standard-theme.css';
@import 'node_modules/@sbb-esta/lyne-elements/standard-theme.css';
```

or editing your `angular.json`:
Expand All @@ -69,7 +69,7 @@ Select your technology to get started.
...
"styles": [
"src/styles.scss",
"node_modules/@sbb-esta/lyne-components/standard-theme.css"
"node_modules/@sbb-esta/lyne-elements/standard-theme.css"
],
...
```
Expand All @@ -82,7 +82,7 @@ Select your technology to get started.
import { CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';

import '@sbb-esta/lyne-components/button.js';
import '@sbb-esta/lyne-elements/button.js';

@Component({
selector: 'my-app',
Expand All @@ -101,23 +101,23 @@ bootstrapApplication(App).catch((err) => console.error(err));
<summary>React/Next.js</summary>

1. Prepare a React and Next.js setup.
2. Install the `@sbb-esta/lyne-components-react` package:
2. Install the `@sbb-esta/lyne-react` package:

```sh
npm install --save @sbb-esta/lyne-components-react
npm install --save @sbb-esta/lyne-react
```

or, if using yarn:

```sh
yarn add @sbb-esta/lyne-components-react
yarn add @sbb-esta/lyne-react
```

3. Including global styles is strongly recommended to apply all SBB styles to your application.
See [styles](#styles) section if you prefer more granularity on what to import.

```css
@import '~@sbb-esta/lyne-components/standard-theme.css';
@import '~@sbb-esta/lyne-elements/standard-theme.css';
```

4. Enhance the `transpilePackages` array in Next.Js config.
Expand All @@ -126,8 +126,8 @@ bootstrapApplication(App).catch((err) => console.error(err));
module.exports = {
...,
transpilePackages: [
'@sbb-esta/lyne-components-react',
'@sbb-esta/lyne-components',
'@sbb-esta/lyne-react',
'@sbb-esta/lyne-elements',
'@lit/react',
'@lit/reactive-element',
'lit',
Expand All @@ -147,8 +147,8 @@ bootstrapApplication(App).catch((err) => console.error(err));
module.exports = withLitSSR({
...,
transpilePackages: [
'@sbb-esta/lyne-components',
'@sbb-esta/lyne-components-react',
'@sbb-esta/lyne-elements',
'@sbb-esta/lyne-react',
'@sbb-esta/lyne-design-tokens',
'@lit-labs/nextjs',
'@lit-labs/ssr',
Expand All @@ -165,18 +165,18 @@ bootstrapApplication(App).catch((err) => console.error(err));
6. Import and use lyne component:

```tsx
import { SbbButton } from '@sbb-esta/lyne-components-react/button';
import { SbbButton } from '@sbb-esta/lyne-react/button';

export default function MyComponent() {
return <SbbButton onClick={() => {}}></SbbButton>;
}
```

Whenever e.g. types are needed, they can be imported directly from the `@sbb-esta/lyne-components` package:
Whenever e.g. types are needed, they can be imported directly from the `@sbb-esta/lyne-elements` package:

```tsx
import type { SbbButtonSize } from '@sbb-esta/lyne-components/button.js';
import { SbbButton } from '@sbb-esta/lyne-components-react/button';
import type { SbbButtonSize } from '@sbb-esta/lyne-elements/button.js';
import { SbbButton } from '@sbb-esta/lyne-react/button';

export default function MyComponent() {
const size: SbbButtonSize = 'm';
Expand Down Expand Up @@ -219,19 +219,19 @@ The `standard-theme.css` (or `core.css`) file only contains a subset of the `SBB
For including the full fontset, we provide the `font-characters-extension.css` file which can be added after the `standard-theme.css` (or `core.css`) file.

```css
@import '@sbb-esta/lyne-components/standard-theme.css';
@import '@sbb-esta/lyne-components/font-characters-extension.css';
@import '@sbb-esta/lyne-elements/standard-theme.css';
@import '@sbb-esta/lyne-elements/font-characters-extension.css';
```

### Design Tokens

The `@sbb-esta/lyne-components` package provides the CSS variable design tokens
The `@sbb-esta/lyne-elements` package provides the CSS variable design tokens
from `@sbb-esta/lyne-design-tokens` in the `standard-theme.css` (or `core.css`).

> If you have to use design tokens within a javascript context,
> please also add `@sbb-esta/lyne-design-tokens` package to your project.

Please check `node_modules/@sbb-esta/lyne-components/standard-theme.css` for available design tokens.
Please check `node_modules/@sbb-esta/lyne-elements/standard-theme.css` for available design tokens.

#### How to work with design tokens

Expand All @@ -248,7 +248,7 @@ Lyne Components provides various SASS mixins which can be used by consumers.
For available SASS mixins, check [SASS Mixins](https://github.com/sbb-design-systems/lyne-components/tree/main/src/components/core/styles/mixins).

```scss
@use '@sbb-esta/lyne-components' as sbb;
@use '@sbb-esta/lyne-elements' as sbb;

.my-class {
@include sbb.grid-base;
Expand Down Expand Up @@ -352,7 +352,7 @@ See [Text styles](https://lyne-storybook.app.sbb.ch/?path=/docs/styles-typograph
```

```scss
@use '@sbb-esta/lyne-components' as sbb;
@use '@sbb-esta/lyne-elements' as sbb;

p {
@include sbb.text-s--bold;
Expand Down
28 changes: 18 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@sbb-esta/lyne-components",
"name": "@sbb-esta/lyne-elements",
"version": "0.51.1",
"description": "Lyne Design System",
"keywords": [
Expand All @@ -21,18 +21,24 @@
"private": true,
"scripts": {
"postinstall": "yarn playwright install",
"build:components": "npm-run-all --sequential build:components:*",
"build:components:production": "vite build --config src/components/vite.config.ts",
"build:components:development": "NODE_ENV=development vite build --mode development --config src/components/vite.config.ts",
"build:react": "npm-run-all --sequential build:react:*",
"build:elements": "npm-run-all --sequential build:elements:* build:elements-experimental:*",
"build:elements:production": "vite build --config src/elements/vite.config.ts",
"build:elements:development": "NODE_ENV=development vite build --mode development --config src/elements/vite.config.ts",
"build:elements-experimental:production": "vite build --config src/elements-experimental/vite.config.ts",
"build:elements-experimental:development": "NODE_ENV=development vite build --mode development --config src/elements-experimental/vite.config.ts",
"build:react": "npm-run-all --sequential build:react:* build:react-experimental:*",
"build:react:production": "vite build --config src/react/vite.config.ts",
"build:react:development": "NODE_ENV=development vite build --mode development --config src/react/vite.config.ts",
"build:react-experimental:production": "vite build --config src/react/experimental-vite.config.ts",
"build:react-experimental:development": "NODE_ENV=development vite build --mode development --config src/react/experimental-vite.config.ts",
"build:storybook": "storybook build --quiet --output-dir dist/storybook --stats-json",
"build:visual-regression-app": "vite build --config src/visual-regression-app/vite.config.ts",
"build": "npm-run-all --sequential build:components build:react build:storybook",
"build": "npm-run-all --sequential build:elements build:react build:storybook",
"docs": "npm-run-all --sequential docs:manifest docs:to-md",
"docs:manifest": "custom-elements-manifest analyze --config tools/manifest/custom-elements-manifest.config.js",
"docs:to-md": "tsx scripts/docs_generate.ts",
"docs:manifest": "npm-run-all --sequential docs:manifest:*",
"docs:manifest:elements": "custom-elements-manifest analyze --config tools/manifest/elements-custom-elements-manifest.config.js",
"docs:manifest:elements-experimental": "custom-elements-manifest analyze --config tools/manifest/elements-experimental-custom-elements-manifest.config.js",
"docs:to-md": "tsx tools/docs/docs_generate.ts",
"format": "prettier \"**/*\" --write --ignore-unknown",
"generate": "tsx tools/generate-component/index.mts",
"generate:chromatic-stories": "tsx scripts/chromatic-stories-generator.ts",
Expand All @@ -46,8 +52,10 @@
"lint:lit": "yarn lit-analyzer \"src/**/*.ts\"",
"lint:circular-imports": "madge --circular --ts-config ./tsconfig.json --extensions ts ./src",
"lint:tsc": "npm-run-all --sequential lint:tsc:*",
"lint:tsc:components": "tsc --noEmit --project src/components/tsconfig.json",
"lint:tsc:components-spec": "tsc --noEmit --project src/components/tsconfig.spec.json",
"lint:tsc:components": "tsc --noEmit --project src/elements/tsconfig.json",
"lint:tsc:components-spec": "tsc --noEmit --project src/elements/tsconfig.spec.json",
"lint:tsc:components-experimental": "tsc --noEmit --project src/elements-experimental/tsconfig.json",
"lint:tsc:components-experimental-spec": "tsc --noEmit --project src/elements-experimental/tsconfig.spec.json",
"lint:tsc:visual-regression-app": "tsc --noEmit --project src/visual-regression-app/tsconfig.json",
"start": "storybook dev -p 6006",
"start:visual-regression-app": "vite --config src/visual-regression-app/vite.config.ts",
Expand Down
2 changes: 1 addition & 1 deletion scripts/migrate-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { basename, dirname } from 'path';
import * as glob from 'glob';

const indexFiles = glob.sync('**/index.ts', {
cwd: dirname(import.meta.resolve('../src/components')),
cwd: dirname(import.meta.resolve('../src/elements')),
absolute: true,
});
for (const indexFile of indexFiles) {
Expand Down
6 changes: 3 additions & 3 deletions scripts/migrate-ssr-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ function* iterate(node: ts.Node): Generator<ts.Node, void, unknown> {
}
}

const testingDir = new URL('../src/components/core/testing', import.meta.url).pathname;
const testingDir = new URL('../src/elements/core/testing', import.meta.url).pathname;
const e2eFiles = glob.sync('**/*.e2e.ts', { cwd: new URL('..', import.meta.url), absolute: true });
const componentIndexes = glob
.sync('src/components/**/index.ts', { cwd: new URL('..', import.meta.url), absolute: true })
.filter((f) => !f.includes('/components/core/'))
.sync('src/elements/**/index.ts', { cwd: new URL('..', import.meta.url), absolute: true })
.filter((f) => !f.includes('/elements/core/'))
.sort()
.sort((a, b) => b.length - a.length);
for (const file of e2eFiles) {
Expand Down
2 changes: 1 addition & 1 deletion scripts/migrate-toggle-data-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function toKebabCase(str: string): string {

// custom ignores can be done like this, for example by saying
// you'll ignore all markdown files, and all folders named 'docs'
const sources = glob.sync('src/components/**/*.ts', {
const sources = glob.sync('src/elements/**/*.ts', {
cwd: new URL('..', import.meta.url),
absolute: true,
ignore: {
Expand Down
Loading
Loading