-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vue)!: add vue transpiler 🚀 (#436)
Co-authored-by: Maurício Mutte <[email protected]>
- Loading branch information
1 parent
f5bec3b
commit 1ff216a
Showing
42 changed files
with
3,605 additions
and
789 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module.exports = { | ||
stories: [ | ||
'../stories/*.stories.@(js|jsx|ts|tsx|mdx)', | ||
'../../../packages/core/src/**/*.vue.stories.@(js|jsx|ts|tsx|mdx)', | ||
], | ||
addons: [ | ||
'@storybook/addon-essentials', | ||
'@storybook/addon-docs', | ||
'@storybook/addon-actions', | ||
'@storybook/addon-a11y', | ||
'@storybook/addon-viewport', | ||
'@storybook/theming', | ||
], | ||
framework: { | ||
name: '@storybook/vue3-vite', | ||
options: {}, | ||
}, | ||
docs: { | ||
autodocs: true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<meta name="robots" content="noindex" /> | ||
|
||
<style> | ||
.sidebar-subheading { | ||
letter-spacing: 0.2em !important; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { addons } from '@storybook/addons' | ||
|
||
import theme from '@atomium/storybook-utils/theme' | ||
|
||
addons.setConfig({ | ||
theme, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CustomViewports } from '@atomium/storybook-utils/custom-viewports' | ||
import DocumentationTemplate from '@atomium/storybook-utils/DocumentationTemplate.mdx' | ||
|
||
import '@atomium/storybook-utils/preview.css' | ||
|
||
import '@juntossomosmais/atomium-tokens/tokens.css' | ||
import '@juntossomosmais/atomium/dist/core/core.css' | ||
|
||
const preview = { | ||
parameters: { | ||
viewport: { | ||
viewports: CustomViewports, | ||
}, | ||
actions: { argTypesRegex: '^atom.*' }, | ||
docs: { | ||
page: DocumentationTemplate, | ||
}, | ||
}, | ||
} | ||
|
||
export default preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@atomium/docs-vue", | ||
"private": true, | ||
"scripts": { | ||
"start": "storybook dev -p 8006 --no-open", | ||
"build": "storybook build -o ../docs/storybook-static/vue" | ||
}, | ||
"nx": { | ||
"targets": { | ||
"build": { | ||
"dependsOn": [ | ||
{ | ||
"projects": [ | ||
"@juntossomosmais/atomium-vue" | ||
], | ||
"target": "build" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Meta } from '@storybook/addon-docs' | ||
|
||
<Meta title='Introduction' /> | ||
|
||
# About Vue Components | ||
|
||
All [Vue Components is generated by Stencil](https://stenciljs.com/docs/vue) using [Stencil's output target](https://stenciljs.com/docs/vue#output-targets) to automatically generate Vue components from our Atomium's web components. | ||
|
||
The target of this stories is run Atomium's web components in Vue environment and show how to use the components. | ||
|
||
**!important** | ||
|
||
There is a problem to render the code of [Vue's components outputed by Stencil in Storybook](https://github.com/storybookjs/storybook/issues/22287), so the code of the components is not shown correctly in the stories. | ||
|
||
Example, in [Button component](?path=/docs/react_components-button--docs): | ||
|
||
```jsx | ||
{ | ||
render: args => createButton(args), | ||
args: { | ||
...ButtonComponentArgs | ||
} | ||
} | ||
``` | ||
|
||
The code above is not shown correctly in the stories, but it is correct in the source code: | ||
|
||
```jsx | ||
<AtomButton color='primary' fill='solid' mode='md' shape='round' type='button'> | ||
Button | ||
</AtomButton> | ||
``` | ||
|
||
Just keep in mind that when check the code of the components inside Storybook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { fileURLToPath, URL } from 'node:url' | ||
|
||
import vue from '@vitejs/plugin-vue' | ||
import { defineConfig } from 'vite' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [vue()], | ||
resolve: { | ||
alias: { | ||
'@': fileURLToPath(new URL('./src', import.meta.url)), | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
...s/0007-why-do-we-transpile-web-components-for-react-and-not-for-vue.stories.mdx
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
...n-records/0007-why-do-we-transpile-web-components-for-react-and-vue.stories.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Meta } from '@storybook/addon-docs' | ||
|
||
<Meta title='Docs/Architecture Decision Records/ADR 0007: Why do we transpile Web Components for React and Vue?' /> | ||
|
||
# ADR 0007: Why do we transpile Web Components for React and Vue? | ||
|
||
🗓️ ~2023-04~ 2024-05 · ✍️ [@felipefialho](https://twitter.com/felipefialho_) | ||
|
||
## Context | ||
|
||
We need to use Web Components in our projects built with Vue and React (Next.js) while maintaining a good Developer Experience (DX). | ||
|
||
## Problems | ||
|
||
### React | ||
|
||
- We need to use `Event Listeners` to handle events and methods when using Web Components | ||
- React [use `SyntheticEvent` to handle events](https://legacy.reactjs.org/docs/events.html), and we need to convert it to `CustomEvent` to use Web Components | ||
- Props that use `array` or `object` need to be converted to JSON for compatibility | ||
- We need to use `ref` to access the Web Component API in React | ||
- Sometimes, we need to create wrappers to effectively use Web Components in React | ||
- Overall, the Developer Experience in React is not optimal when working with Web Components | ||
|
||
### Vue | ||
|
||
- Props that use `array` or `object` need to be converted to JSON for compatibility | ||
- We need to use `ref` to access the Web Component API in Vue | ||
- We need to create wrappers to effectively use Web Components in Vue and it is not always straightforward | ||
|
||
## Decision | ||
|
||
~To address these challenges, we have decided to use Stencil to create a transpiled version of Web Components specifically for React, while keeping the original version for Vue.~ | ||
|
||
~Currently, we are using Vue 2 (as of April 2022), and the transpiler of Stencil is not compatible with Vue 2, however, Vue provides a good DX and seamless compatibility with Web Components.~ | ||
|
||
~In the future, when we migrate to Vue 3, we may reevaluate this decision and consider transpiling Web Components for Vue as well.~ | ||
|
||
### Update | ||
|
||
Now we are using Vue 3, and we have decided to transpile Web Components for both React and Vue to provide a better Developer Experience (DX) and to ensure compatibility with the latest versions of both libraries. |
Oops, something went wrong.