Skip to content

Commit

Permalink
Initial Polaris 12 - complete scaffold & AppProvider component
Browse files Browse the repository at this point in the history
  • Loading branch information
juzser committed Nov 29, 2023
1 parent d98fe6f commit b288864
Show file tree
Hide file tree
Showing 822 changed files with 2,384 additions and 57,406 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "polaris"]
path = polaris
url = https://github.com/Shopify/polaris
48 changes: 24 additions & 24 deletions .postcssrc.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const postcssModules = require('postcss-modules');
const classConfig = require('./build/namespaced-classname');
// const postcssModules = require('postcss-modules');
// const classConfig = require('./build/namespaced-classname');

module.exports = {
plugins: [
postcssModules({
generateScopedName: classConfig,
getJSON: (cssFileName, json) => {
/* Ignore generate common polaris tokens style file */
if (cssFileName.indexOf('@shopify/polaris-tokens') !== -1) {
return;
}
// plugins: [
// postcssModules({
// generateScopedName: classConfig,
// getJSON: (cssFileName, json) => {
// /* Ignore generate common polaris tokens style file */
// if (cssFileName.indexOf('@shopify/polaris-tokens') !== -1) {
// return;
// }

let cssName = path.basename(cssFileName, '.vue');
// let cssName = path.basename(cssFileName, '.vue');

let projectPath = path.basename(__dirname, './');
// let projectPath = path.basename(__dirname, './');

const pattern = new RegExp(`${projectPath}/src/components/(.*?)/components`, 'g');
let parentName = cssFileName.match(pattern);
if (parentName) {
parentName = parentName[0].replace(pattern, '$1');
}
// const pattern = new RegExp(`${projectPath}/src/components/(.*?)/components`, 'g');
// let parentName = cssFileName.match(pattern);
// if (parentName) {
// parentName = parentName[0].replace(pattern, '$1');
// }

// Fix rollup repeat
cssName = cssName.replace(/(.*)\.vue\?.*/, '$1');
const jsonFileName = path.resolve(`./src/classes/${parentName ? `${parentName}-` : ''}${cssName}.json`);
fs.writeFileSync(jsonFileName, JSON.stringify(json));
},
}),
],
// // Fix rollup repeat
// cssName = cssName.replace(/(.*)\.vue\?.*/, '$1');
// const jsonFileName = path.resolve(`./src/classes/${parentName ? `${parentName}-` : ''}${cssName}.json`);
// fs.writeFileSync(jsonFileName, JSON.stringify(json));
// },
// }),
// ],
};
169 changes: 11 additions & 158 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,165 +1,18 @@
# Polaris Vue (Support Vue 3.0)
# Vue 3 + TypeScript + Vite

Polaris Vue by Ownego only supports **Vue 3.0+**.
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

Polaris Vue based on [Shopify Polaris style guide](https://polaris.shopify.com/), built especially for Vue 3.
We're trying to make it mostly close with Shopify style guide and get a better performance.
## Recommended IDE Setup

**Follow Polaris React version:** [10.12.0](https://github.com/Shopify/polaris/releases/tag/%40shopify%2Fpolaris%4010.12.0) - Migrated date: *Nov 23rd, 2022*.
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).

---
## Type Support For `.vue` Imports in TS

We're using this library for our apps and got `Built for Shopify` badge, so hopefully it will be helpful for you too.
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.

<img width="631" alt="Screenshot 2023-07-03 at 15 35 54" src="https://github.com/ownego/polaris-vue/assets/5735071/90b10b70-0113-4633-93bf-678cfe1a92db">
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:



<br/>

## Documentation

Online documentation: [Click Here](https://ownego.github.io/polaris-vue/)

<br/>

## Installation

Via NPM:

```bash
npm install @ownego/polaris-vue
```

Via Yarn:

```bash
yarn add @ownego/polaris-vue
```

<br/>

## Usage

Use as a Vue 3 plugin (globally registers all components):

```js
//main.js
import { createApp } from 'vue'
import PolarisVue from '@ownego/polaris-vue' // (✓)
import '@ownego/polaris-vue/dist/style.css' // (✓) This will be deprecated in the future, right after Vue 3 supports css injections.
import App from './App.vue'

//...
const app = createApp(App)
app.use(PolarisVue) // (✓)
...
```

**OR** use individual component:

```js
import { List, Icon } from '@ownego/polaris-vue';
```

<br/>

### **AppProvider**
The AppProvider component is `required` to use PolarisVue. Without it, the components in your application will not function correctly. You must wrap the root (the top) of your application in the app provider component.

```javascript
// App.vue
<template>
<AppProvider>
...
</AppProvider>
</template>

<script></script>
```


## NUXT 3

We have tested support for Nuxt 3 in non-SSR mode only. To use with Nuxt 3, follow the below configuration and then use the plugin in your components/pages

### Plugin File

Create a new plugin file at `<project-root>/plugins/polaris.client.ts` and update the content to following

```ts
import PolarisVue from "@ownego/polaris-vue";
import "@ownego/polaris-vue/dist/style.css";

export default defineNuxtPlugin(nuxtApp => {
nuxtApp.vueApp.use(PolarisVue);
});
```

### Nuxt Config

Update `<project-root>/nuxt.config.ts` to include following config values

```ts
export default defineNuxtConfig({
...
build: {
transpile: ["@ownego/polaris-vue"],
},
...
});
```


## De-duplicating Vue version

`PolarisVue`, other packages and your project may require access to the global Vue reference. So sometimes, you may get the runtime error message like:

```bash
TypeError: Cannot read properties of null (reading 'isCE')
renderSlot(...)
...
```

To avoid this, simply add `dedupe: ['vue']` to your `vite.config.ts` file, like below:

```bash
export default defineConfig({
resolve: {
...
dedupe: ['vue'],
},
...
});
```

---

## Developers / Build

```bash
# Clone repo
git clone https://github.com/ownego/polaris-vue.git

# Install packages
yarn

# Create a Demo.vue file to test

# Development & Demo
yarn dev
```

## Contributing

Polaris Vue by Ownego is an open source project and we are very happy to accept community contributions.

If you notice any bugs, please create issues under [Issues](https://github.com/ownego/polaris-vue/issues).
We will update the contribution rules later.

## License

Code released under the [MIT License](https://github.com/ownego/polaris-vue/LICENSE).
Copyright (c) 2021 Ownego

**Thank you!** :tada:
1. Disable the built-in TypeScript Extension
1. Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2. Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
1 change: 1 addition & 0 deletions types/tsx.d.ts → dts/tsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare global {
namespace JSX {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface Element extends VNode {}
interface ElementClass extends Vue {}
interface IntrinsicElements {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[elem: string]: any;
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<title>Vite + Vue + TS</title>
</head>
<body>
<div id="app"></div>
Expand Down
79 changes: 23 additions & 56 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@ownego/polaris-vue",
"version": "1.3.11",
"polaris_version": "10.12.0",
"description": "Shopify Polaris UI library for Vue 3",
"version": "2.0.0-beta.1",
"polaris_version": "12.1.1",
"description": "Shopify Polaris 12 - UI library for Vue 3",
"author": "Ownego Team",
"keywords": [
"polaris",
Expand All @@ -24,68 +24,35 @@
"module": "./dist/polaris-vue.es.js",
"scripts": {
"dev": "vite",
"build": "rimraf dist && vue-tsc --noEmit && vite build && npm run gen-volar-dts && npm run remove-trashes",
"build": "rimraf dist && vue-tsc --noEmit && vite build && npm run gen-dts && npm run remove-trashes",
"preview": "vite preview --port 5050",
"typecheck": "vue-tsc --noEmit",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"storybook": "start-storybook -p 6006",
"build-storybook": "rimraf ./docs && build-storybook -o docs",
"gen-volar-dts": "esbuild build/gen-component-declaration.js --bundle --platform=node | node && npm run move-volar-dts",
"move-volar-dts": "mv volar.d.ts dist/volar.d.ts",
"gen-dts": "esbuild build/gen-component-declaration.js --bundle --platform=node | node && npm run move-dts",
"move-dts": "mv volar.d.ts dist/volar.d.ts",
"remove-trashes": "rimraf dist/index.html dist/favicon.ico dist/images"
},
"dependencies": {
"@shopify/polaris-icons": "^6.5.0",
"vite-svg-loader": "^3.1.2",
"vue": "^3.2.31",
"vue-router": "^4.1.6"
"@shopify/polaris-icons": "^7.9.0"
},
"devDependencies": {
"@babel/core": "^7.17.5",
"@rushstack/eslint-patch": "^1.1.0",
"@shopify/polaris-tokens": "^6.3.0",
"@shopify/typescript-configs": "^5.1.0",
"@storybook/addon-a11y": "^6.5.5",
"@storybook/addon-actions": "^6.5.5",
"@storybook/addon-docs": "^6.5.5",
"@storybook/addon-essentials": "^6.5.5",
"@storybook/addon-links": "^6.5.5",
"@storybook/addons": "^6.5.5",
"@storybook/builder-vite": "^0.1.35",
"@storybook/theming": "^6.5.5",
"@storybook/vue3": "^6.5.5",
"@types/node": "^16.11.25",
"@vitejs/plugin-vue": "^2.2.4",
"@volar/vue-language-plugin-pug": "^1.0.9",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/tsconfig": "^0.1.3",
"babel-loader": "^8.2.3",
"change-case": "^4.1.2",
"eslint": "^8.10.0",
"eslint-plugin-storybook": "^0.5.12",
"eslint-plugin-vue": "^8.5.0",
"fs-extra": "^10.1.0",
"hash-generator": "^0.1.0",
"path": "^0.12.7",
"polaris": "https://github.com/juzser/polaris.git",
"postcss": "^7",
"postcss-modules": "^3",
"prettier": "^2.5.1",
"process": "^0.11.10",
"rimraf": "^3.0.2",
"sass": "^1.49.8",
"ts-dedent": "^2.2.0",
"typescript": "~4.5.5",
"vite": "^2.8.6",
"vite-plugin-checker": "^0.4.2",
"vite-plugin-dts": "^1.2.0",
"vite-plugin-eslint": "^1.3.0",
"vite-plugin-replace": "^0.1.1",
"vue-tsc": "^0.32.1"
"@shopify/polaris-tokens": "^8.1.0",
"@vitejs/plugin-vue": "^4.5.0",
"@volar/vue-language-plugin-pug": "^1.6.5",
"@vue/language-plugin-pug": "^1.8.22",
"eslint": "^8.54.0",
"eslint-plugin-vue": "^9.18.1",
"pug": "^3.0.2",
"sass": "^1.69.5",
"typescript": "^5.3.2",
"url": "^0.11.3",
"vite": "^5.0.2",
"vite-plugin-dts": "^3.6.3",
"vite-plugin-eslint": "^1.8.1",
"vue": "^3.3.8",
"vue-tsc": "^1.8.22"
},
"peerDependencies": {
"vue": "^3.2.31"
"vue": "^3.3"
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions polaris
Submodule polaris added at 97683a
Binary file removed public/favicon.ico
Binary file not shown.
Binary file removed public/images/banner.jpg
Binary file not shown.
Binary file removed public/images/brand.png
Binary file not shown.
Binary file removed public/images/logo-large.png
Binary file not shown.
Binary file removed public/images/logo.png
Binary file not shown.
17 changes: 0 additions & 17 deletions public/index.html

This file was deleted.

3 changes: 0 additions & 3 deletions src/assets/spinner-large.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/assets/spinner-small.svg

This file was deleted.

1 change: 1 addition & 0 deletions src/assets/vue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/classes/AccountConnection.json

This file was deleted.

1 change: 0 additions & 1 deletion src/classes/ActionList.json

This file was deleted.

Loading

0 comments on commit b288864

Please sign in to comment.