Skip to content

Commit b9dba0e

Browse files
mukunkugiamirdancormier
authored
SPARK-48: Publish Stacks-Svelte (#1991)
* fix stacks classic readme * initial bulk move * move folders around and bring latest toast changes from the old repo * package-lock.json * package.json tweaks * prettier format * fix node_modules path * add local build script to get storybooks working * bump some package versions * package-lock.json * fix storybook and most of the tests setup in this commit I have done the following: - ensure that the correct typescript config is picked up by the svelte config (and consequentially vite) - ensure that svelte-sonnet does not get prebundled by esbuild (this was causing issues for the tests) - Keep peer dependencies for stacks svelte marked (we cannot put * because that would indicate that consumers can install any svelte or stacks classic version which is not the case) - Adjust stacks svelte web test runner config to point at the css bundle generated in stacks classic and also ensure that a fresh build of stacks classic is run before running the tests (I also removed the reference to stacks.js because we don't depend on that in stacks-svelte) - IMPORTANT: Ensure that storybook point at our stacks.less bundle in the preview.ts file. This has the benefit that whatever styles we change in stacks classic it will be hot reloaded in storybook (this is pretty much the whole point why we switch to monorepo - make a change in stacks classic and see it reflected in stacks svelte in a matter of milliseconds - pretty cool :) ) - There are 2 unit tests failing for the Select component - I have not looked too much into it because the component need to be migrated to use the new Svelte 5 runes API. Before spending too much time trying to debug the tests I would rather go ahead and migrate it. It should be rather simple. * small tweaks * adjust test workflows to integrate stacks-svelte * we need to build to test in ci * pass workspaces * run tests individually * add dependency includes to vite * lint fixes also don't fail fast * lint fixes * rename workflow * create netlify.toml for stacks-svelte * adjust readme's * remove Okta login from svelte docs site * disable git lfs in netlify.toml * move git_lfs_enabled to env variables section * add comment * fix quotes * tweak storybook overview doc * fix org name and version * adjust readme * adjust changeset for stacks-svelte * fix expected workflow * adjust names further * append workspace to svelte commands * updated the UserCard for deleted=true prop * formatting --------- Co-authored-by: Giamir Buoncristiani <[email protected]> Co-authored-by: Dan Cormier <[email protected]> Co-authored-by: Dan Cormier <[email protected]>
1 parent 25098de commit b9dba0e

File tree

116 files changed

+14467
-865
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+14467
-865
lines changed

.changeset/cyan-teachers-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stackoverflow/stacks-svelte": minor
3+
---
4+
5+
[SPARK- 48] - publish stacks svelte to npm

.changeset/mean-nails-say.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@stackeng/stacks-svelte": patch
3+
---
4+
5+
Updating UserCard to show deleted User without badges, rep, user type, etc.

.github/workflows/workflow.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
name: ${{ matrix.command_description }}
1616
uses: ./.github/workflows/test.yml
1717
strategy:
18-
fail-fast: true
18+
fail-fast: false
1919
matrix:
2020
include:
2121
- command_description: Build
@@ -42,8 +42,12 @@ jobs:
4242
command: npm run test:visual:ci -w packages/stacks-classic -- --config ./visual-runner/stacks-classic-runner-config/web-test-runner.config.ci.mjs
4343
needs_lfs: true
4444
needs_playwright: false # we are using playwright docker image to run visual tests
45+
- command_description: Unit Tests (stacks-svelte)
46+
command: npm run test -w packages/stacks-svelte
47+
needs_lfs: false
48+
needs_playwright: true
4549
with:
4650
command: ${{ matrix.command }}
4751
command_description: ${{ matrix.command_description }}
4852
needs_playwright: ${{ matrix.needs_playwright }}
49-
needs_lfs: ${{ matrix.needs_lfs }}
53+
needs_lfs: ${{ matrix.needs_lfs }}

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,11 @@ dist/
8787
# Editors #
8888
###########
8989
/.idea
90+
91+
# Stacks-Svelte
92+
################
93+
**/storybook-static
94+
.eslintcache
95+
*.tsbuildinfo
96+
.svelte-kit
97+
/packages/stacks-svelte/lib/

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.md
22
.vscode/
33
dist/
4+
**/.svelte-kit
45
# TODO: prettier breaks less files containing namespaced mixins with whitespaces
56
# BEFORE PRETTIER: #stacks-internals #responsify('.w25', { width: 25% !important; });
67
# AFTER PRETTIER: #stacks-internals #responsify('.w25', { width: 25% !important; });;

CHANGELOG.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

README.md

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
# Stacks
22

3-
[![ci status][gh-action-badge]][gh-action-url] [![npm version][npm-badge]][npm-url]
4-
53
Stacks is Stack Overflow’s design system. It includes the resources needed to create consistent, predictable interfaces and workflows that conform to Stack Overflow’s principles, design language, and best practices.
64

75
Our documentation is built with Stacks itself, using its [immutable, atomic classes](http://johnpolacek.com/rethinking/) and components.
86

97
The Stacks website documents:
108

11-
### Product
9+
## Product
1210
- Semantic and accessible component markup
1311
- Cross-browser compatible Less / CSS
1412
- An [icon library](https://github.com/StackExchange/Stacks-Icons)
13+
- Svelte implementation of our library
1514

16-
### Email
15+
## Email
1716
- Email templates & components
1817

19-
Stacks documentation can be found at https://stackoverflow.design/
20-
2118
## Table of contents
2219

2320
- [Using Stacks](#using-stacks)
@@ -30,14 +27,14 @@ Stacks documentation can be found at https://stackoverflow.design/
3027
- [Contributing](#contributing)
3128
- [License](#license)
3229

33-
## Using Stacks
30+
# Using Stacks
3431
Using Stacks is outlined in our [usage guidelines](https://stackoverflow.design/product/develop/using-stacks).
3532

3633
## Migrating from v1 to v2
3734

3835
To migrate from Stacks v1 to v2, see our [migration guide](/MIGRATION_GUIDE.md).
3936

40-
## Local Development
37+
# Local Development
4138

4239
This repo follows a monolithic structure and contains multiple packages split into [npm workspaces](https://docs.npmjs.com/cli/v9/using-npm/workspaces). These can be found under the [packages/](https://github.com/StackExchange/Stacks/tree/develop/packages) folder.
4340

@@ -58,10 +55,14 @@ npm start
5855
```
5956
This command will pull up the local dev server at http://localhost:8080. You can also view our [building guidelines](https://stackoverflow.design/product/develop/building).
6057

61-
## Stacks Classic
58+
## Stacks Classic
59+
60+
[![ci status][gh-action-badge]][gh-action-url] [![npm version][npm-badge]][npm-url]
6261

6362
This workspace contains the css and js sources that define and power the Stacks design system.
6463

64+
### Formatting
65+
6566
Format the source code with prettier by running:
6667
```sh
6768
npm run format -w packages/stacks-classic
@@ -143,7 +144,46 @@ Update the css snapshots via:
143144
npm run test:less:update -w packages/stacks-classic
144145
```
145146

146-
## Releasing a new version of Stacks Docs / Stacks Classic
147+
## Stacks Svelte
148+
149+
This workspace contains a Svelte implementation of the Stacks Classic design system. Unlike the Stacks-Classic workspace which has its documentation defined in the separate Stacks-Docs workspace, this one defines its documentation site directly within its own workspace which can be reached via https://svelte.stackoverflow.design
150+
151+
We use [storybook](https://storybook.js.org/) for local development. To start the storybook server run:
152+
153+
```bash
154+
npm run storybook -w packages/stacks-svelte
155+
```
156+
157+
The storybook server will reflect the changes you make to the components stories in real time.
158+
We use [this addon](https://storybook.js.org/addons/@storybook/addon-svelte-csf) to write stories directly in Svelte syntax. Stories need to have the `*.stories.svelte` extension to be picked up.
159+
160+
### Formatting
161+
162+
```bash
163+
npm run format -w packages/stacks-svelte
164+
```
165+
166+
### Linting
167+
168+
```bash
169+
npm run lint -w packages/stacks-svelte
170+
```
171+
172+
### Testing
173+
174+
Stacks Svelte uses [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/) and [Playwright](https://modern-web.dev/docs/test-runner/browser-launchers/playwright/) to run tests in a real browser context.
175+
176+
```bash
177+
npm run test -w packages/stacks-svelte
178+
```
179+
180+
or to run the tests in watch mode:
181+
182+
```bash
183+
npm run test:watch -w packages/stacks-svelte
184+
```
185+
186+
# Releasing a new version of Stacks Docs + Stacks Classic or Stacks Svelte
147187
This repo uses [Semantic Versioning](https://semver.org/) to distribute Stacks Classic and Stacks Docs via [npm](https://www.npmjs.com/package/@stackoverflow/stacks), and publishes [release notes on Github](https://github.com/StackExchange/Stacks/releases).
148188

149189
We use [changesets](https://github.com/changesets/changesets) to automatize the steps necessary to publish to NPM, create GH releases and a changelog.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Localization
2+
3+
**Date:** 2024-01-04
4+
5+
**Related PR:** [#46](https://github.com/StackEng/Stacks-Svelte/pull/46)
6+
7+
## Issue
8+
9+
As more complex components are landing into Stacks Svelte (e.g. Modal, TextInput, etc...) we need a strategy to localize the text contained in those components (e.g. Close Button Label in the Modal) rather than keeping it hardcoded.
10+
11+
## Decision
12+
13+
We decided to delegate localization and translation concerns to consumers of the library exposing optional props prefixed by `i18n`. The default value of these props will be the English translation (which we will always fallback to in case consumer don't specify the props).
14+
**No hardcoded text is allowed in any component under any circumnstances.**
15+
16+
Example:
17+
18+
```svelte
19+
<Modal id="modal-example" visible={true} i18nCloseButtonLabel="Chiudi">
20+
```
21+
22+
## Rationale
23+
24+
Using props and delegating localization concerns to the consumers of the library is the simplest approach we can take to ship components that can be correctly rendered in internationalized pages and apps.
25+
The picked approach will also make consumption of those components possible with different translation engines (e.g. moonspeak in Core, a potential new translation engine, etc...).
26+
The downside of the approach is that the API of the components could become a bit bloated with a proliferation of optional props dedicated to pass on localized text. It also create more work for consumers who need to curate and provide the translations.
27+
28+
We have considered maintaining localization files for primary languages ourselves and provide the ability for consumers to register their own translations. This solution would be more complex and it will increase maintainance work on our small team therefore we decided to avoid it for now.
29+
30+
We don't exclude providing a different way for consumer to localize Stacks Svelte components in the future as the community tools and best practices on this topic evolve. We also expect this ADR to evolve over time as our library grow (e.g. if/when we will introduce a date picker).
31+
32+
## Further Reading
33+
34+
- [Carbon Svelte Component Library using props for localization](https://github.com/carbon-design-system/carbon-components-svelte/issues/858)
35+
- [SvelteKit i18n brainstorming thread](https://github.com/sveltejs/kit/issues/553)

0 commit comments

Comments
 (0)