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

Core update / d3 micro modules #71

Merged
merged 33 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a35c303
core: updated core master
palerdot Feb 28, 2024
aa95bc3
feat: pnpm
palerdot Feb 28, 2024
2d3289a
vue, vite package upgrade
palerdot Feb 28, 2024
8af972f
happy dom
palerdot Feb 28, 2024
c4de1d5
memoize one
palerdot Feb 28, 2024
0cdb240
d3 micro modules
palerdot Feb 28, 2024
f25303f
min node, npm upgrade
palerdot Feb 28, 2024
2a64f61
moving to happy-dom
palerdot Feb 28, 2024
e2ff013
switch to d3-selection import
palerdot Feb 28, 2024
a1b814a
@rollup/plugin-terser
palerdot Feb 28, 2024
6318ab8
trying unaliasing esm build
palerdot Feb 28, 2024
d5bbc50
package upgrades
palerdot Feb 28, 2024
f3c4eac
storybook: v7
palerdot Feb 28, 2024
f0223ba
lint fix
palerdot Feb 28, 2024
057a554
feat: SFC and composition api rewrite
palerdot Feb 29, 2024
9e181e2
vue 3.3 as peer dependency
palerdot Feb 29, 2024
31a29f0
prod build setup change
palerdot Feb 29, 2024
874dc5a
theme tweaks
palerdot Feb 29, 2024
ab77d20
theme changes with manager-api dependency
palerdot Feb 29, 2024
8a6e7f1
feat: slim build
palerdot Feb 29, 2024
652a94b
docs: segmentValueFormatter props
palerdot Feb 29, 2024
05c0ae1
docs: segmentValueFormatter story
palerdot Feb 29, 2024
e82830b
docs(README): v3 info
palerdot Feb 29, 2024
c6d187e
docs(README): slim build info
palerdot Feb 29, 2024
d0de278
vue3 sfc component tests
palerdot Feb 29, 2024
98137bf
gh actions: node 18 for tests
palerdot Feb 29, 2024
57495e5
gh actions: change task runner to npm
palerdot Feb 29, 2024
67fc025
gh actions: change task runner to npm
palerdot Feb 29, 2024
a549768
remove unused functions
palerdot Feb 29, 2024
5957122
remove unnecessary circle ci task
palerdot Feb 29, 2024
401003e
refactor: export enums from main vue file
palerdot Feb 29, 2024
792e30f
remove es6 exports from script setup
palerdot Feb 29, 2024
704a26b
docs(README): script setup example
palerdot Feb 29, 2024
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
30 changes: 0 additions & 30 deletions .circleci/config.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

strategy:
matrix:
node-version: [16.x]
node-version: [18.x]

steps:
- name: Checkout repository
Expand Down
14 changes: 11 additions & 3 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module.exports = {
"../src/stories/**/*.stories.mdx",
"../src/stories/**/*.stories.@(js|jsx|ts|tsx)",
],

addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
core: {
builder: "@storybook/builder-vite", // 👈 The builder enabled here.
},

async viteFinal(config, { configType }) {
// customize the Vite config here
return {
Expand All @@ -17,4 +16,13 @@ module.exports = {
},
}
},

framework: {
name: "@storybook/vue3-vite",
options: {}
},

docs: {
autodocs: true
}
}
3 changes: 2 additions & 1 deletion .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { addons } from "@storybook/addons"
import { create } from "@storybook/theming/create"
import { themes, create } from "@storybook/theming/create"
import theme from "../src/core/theme"

const speedoTheme = create({
...themes.dark,
...theme,

brandTitle: "vue-speedometer",
Expand Down
16 changes: 10 additions & 6 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
// ref: https://www.npmjs.com/package/@storybook/vue3
import { app } from "@storybook/vue3"
// ref: https://github.com/storybookjs/storybook/issues/19295
import { setup } from "@storybook/vue3"

// DEVELOPMENT: 'src/index.js'
import VueSpeedometer from "../src/index"
import VueSpeedometer from "../src/index.vue"
// PRODUCTION build testing
// import VueSpeedometer from "../dist/index"

app.component("vue-speedometer", VueSpeedometer)
app.mixin({
/* My mixin */
//
setup(app => {
app.component("vue-speedometer", VueSpeedometer)
app.mixin({
/* My mixin */
})
})

27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,15 @@

![vue-speedometer](https://raw.githubusercontent.com/palerdot/vue-speedometer/master/speedo.gif)

Note: v2.x is compatible with `Vue 3`. Please use latest v1.x (v1.8.0 at the time of writing) if you are using `Vue 2`.
**IMPORTANT** `v3.0` is released which is a complete rewrite with composition api/SFC (single file components). Minimum required vue version is `v3.3`. If you are using Vue 3 composition api, please upgrade to `v3`

Note: v2.x is still compatible with `Vue 3`. Please use latest v1.x (v1.8.0 at the time of writing) if you are using `Vue 2`.

## Usage:

**pnpm:**
`pnpm add vue-speedometer`

**Yarn:**
`yarn add vue-speedometer`

Expand All @@ -23,16 +28,27 @@ Note: v2.x is compatible with `Vue 3`. Please use latest v1.x (v1.8.0 at the tim

```javascript
// import the component
<script setup>
import VueSpeedometer from "vue-speedometer"
</script>
// and use it in your component like
export default {
components: { VueSpeedometer },
template: `<vue-speedometer />`,
}
<template>
<VueSpeedometer />
</template>
```

`vue-speedometer` is the name of the component to be used inside Vue templates

### Slim Build (Experimental):

There is a `Slim` build available without bundling `d3`. This project uses `d3` *micro bundles*. If your project also uses `d3` *microbundles*, you can opt for **slim build**. Necessary `d3` dependencies required for slim build to work are - `d3-array`, `d3-color`, `d3-ease`, `d3-format`, `d3-interpolate`, `d3-scale`, `d3-selection`, `d3-shape`, `d3-transition`.
```javascript
// sample slim build usage
import VueSpeedometer from "vue-speedometer/slim"
// and use it
<VueSpeedometer />
```

## Ports:
- React: [react-d3-speedometer](https://github.com/palerdot/react-d3-speedometer)
- Svelte: [svelte-speedometer](https://github.com/palerdot/svelte-speedometer)
Expand Down Expand Up @@ -69,6 +85,7 @@ You can view [Live Examples here](https://palerdot.in/vue-speedometer/)
| ringWidth | Number | 60 | Width of the speedometer ring. |
| textColor | String | #666 | Should be a valid color code - colorname, hexadecimal name or rgb value. Used for both showing the current value and the segment values |
| valueFormat | String | | should be a valid format for [d3-format](https://github.com/d3/d3-format#locale_format). By default, no formatter is used. You can use a valid d3 format identifier (for eg: `d` to convert float to integers), to format the values. **Note:** This formatter affects all the values (current value, segment values) displayed in the speedometer |
| segmentValueFormatter | Function | value => value | Custom segment values formatter function. This function is applied after 'valueFormat' prop if present. |
| currentValueText | String | ${value} | Should be provided a string which should have **${value}** placeholder which will be replaced with current value. By default, current value is shown (formatted with `valueFormat`). For example, if current Value is 333 if you would like to show `Current Value: 333`, you should provide a string **`Current Value: ${value}`**. See [Live Example](https://palerdot.in/vue-speedometer/?selectedKind=vue-speedometer&selectedStory=Custom%20Current%20Value%20Text&full=0&down=1&left=1&panelRight=0) |
| currentValuePlaceholderStyle | String | ${value} | Should be provided a placeholder string which will be replaced with current value in `currentValueTextProp`. For example: you can use ruby like interpolation by giving following props - `<vue-speedometer currentValueText="Current Value: #{value}" currentValuePlaceholderStyle={"#{value}"} />`. This is also helpful if you face `no-template-curly-in-string` eslint warnings and would like to use different placeholder for current value |
| customSegmentStops | Array | [] | Array of values **starting** at `min` value, and **ending** at `max` value. This configuration is useful if you would like to split the segments at custom points or have unequal segments at preferred values. If the values does not begin and end with `min` and `max` value respectively, an error will be thrown. This configuration will override `segments` prop, since total number of segments will be `length - 1` of `customSegmentProps`. For example, `[0, 50, 75, 100]` value will have three segments - `0-50`, `50-75`, `75-100`. See [Live Example](https://palerdot.in/vue-speedometer/?path=/story/vue-speedometer--custom-segment-stops) |
Expand Down
13 changes: 8 additions & 5 deletions cypress.config.js → cypress.config.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const { defineConfig } = require("cypress")
const vitePreprocessor = require("cypress-vite")

module.exports = defineConfig({
video: false,
Expand All @@ -17,9 +18,11 @@ module.exports = defineConfig({
},
},

// e2e: {
// setupNodeEvents(on, config) {
// // implement node event listeners here
// },
// },
// ref: https://www.npmjs.com/package/cypress-vite
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
on("file:preprocessor", vitePreprocessor())
},
},
})
2 changes: 1 addition & 1 deletion lib/d3-speedometer
Submodule d3-speedometer updated 46 files
+13 −4 .github/workflows/workflow.yml
+0 −27 .scripts/prepublish.sh
+0 −1 .scripts/user/prepublish.sh
+0 −1 .scripts/user/pretest.js
+0 −6 .storybook/babel.config.js
+30 −14 .storybook/main.js
+12 −3 .storybook/manager.js
+3 −0 .storybook/preview-head.html
+2 −25 .storybook/preview.js
+9 −0 CHANGELOG.md
+15 −3 README.md
+0 −43 babel.config.js
+20 −0 cypress.config.ts
+5 −0 cypress/fixtures/example.json
+33 −0 cypress/plugins/index.js
+25 −0 cypress/support/commands.js
+37 −0 cypress/support/commands.ts
+12 −0 cypress/support/component-index.html
+39 −0 cypress/support/component.ts
+20 −0 cypress/support/e2e.ts
+23 −0 cypress/support/index.js
+77 −47 package.json
+16,112 −0 pnpm-lock.yaml
+6 −0 setupVitest.js
+93 −0 slim.config.js
+86 −0 src/__tests__/ForceRender.spec.jsx
+19 −0 src/__tests__/ReactSpeedometer.spec.jsx
+356 −0 src/__tests__/ReactSpeedometer.test.jsx
+0 −496 src/__tests__/index.js
+87 −0 src/__tests__/utils.test.jsx
+2 −1 src/core/config/configure.js
+12 −6 src/core/config/index.js
+20 −9 src/core/render/index.js
+4 −0 src/core/theme/index.js
+1 −2 src/core/util/get-needle-transition.js
+1 −1 src/core/util/index.js
+60 −30 src/core/util/index.test.js
+2 −0 src/index.d.ts
+17 −3 src/index.jsx
+44 −11 src/stories/ReactSpeedometer.stories.jsx
+0 −0 src/stories/auto-refresh.jsx
+0 −0 src/stories/multi-speedometers.jsx
+0 −0 src/stories/speedo-button.jsx
+76 −0 vite.config.js
+12 −0 vitest.config.js
+0 −13,050 yarn.lock
1 change: 1 addition & 0 deletions nyc.config.js → nyc.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module.exports = {
"report-dir": "cypress-coverage",
"check-coverage": true,
include: ["src"],
extension: [".js", ".vue"],
exclude: ["src/stories", "src/core", "src/__tests__", "src/index.d.ts"],
}
67 changes: 42 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"name": "palerdot",
"email": "[email protected]"
},
"type": "module",
"files": [
"dist"
],
Expand All @@ -14,23 +15,27 @@
"module": "./dist/vue-speedometer.es.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/vue-speedometer.es.js",
"require": "./dist/vue-speedometer.umd.js"
},
"./slim": {
"import": "./dist/slim/index.js"
}
},
"scripts": {
"lint": "prettier -l src/index.js src/props.js src/__tests__/**/**.js",
"build-storybook": "build-storybook -o .out",
"build-storybook": "storybook build -o .out",
"init-submodule": "git submodule update --init",
"lintfix": "prettier --write src/index.js src/props.js src/__tests__/**/**.js",
"publish-storybook": "bash .scripts/publish_storybook.sh",
"pull-submodules": "git submodule foreach git pull origin master",
"storybook": "start-storybook -p 6006",
"storybook": "storybook dev -p 6006",
"test": "vitest",
"pretest": "rm -rf .nyc_output || true",
"full-test": "vitest run && yarn instrument-code && yarn cy:run && yarn clean:instrumented-code",
"clean:instrumented-code": "rm -rf instrumented",
"instrument-code": "yarn clean:instrumented-code && npx nyc instrument --compact=false src instrumented && cp -R src/core instrumented/",
"instrument-code": "npm run clean:instrumented-code && npx nyc instrument --compact=false src instrumented && cp -R src/core instrumented/",
"mkdir:reports": "mkdir reports || true",
"precopy:reports": "npm run mkdir:reports",
"copy:reports": "cp cypress-coverage/coverage-final.json reports/from-cypress.json || true",
Expand All @@ -43,51 +48,63 @@
"cy:open": "cypress open",
"build": "npm run build:main && npm run build:slim && npm run copy:types",
"build:main": "NODE_ENV=production vite build",
"build:slim": "echo 'porumai ... slim build coming soon'",
"build:slim": "NODE_ENV=production vite build -c slim.config.js",
"copy:types": "cp ./src/index.d.ts ./dist/",
"prepublishOnly": "npm run build",
"preview": "vite preview"
},
"dependencies": {
"d3": "^5.9.2",
"d3-array": "^3.1.4",
"d3-color": "^3.1.0",
"d3-ease": "^3.0.1",
"d3-format": "^3.1.0",
"d3-interpolate": "^3.0.1",
"d3-scale": "^4.0.2",
"d3-selection": "^3.0.0",
"d3-shape": "^3.1.0",
"d3-transition": "^3.0.1",
"lodash-es": "^4.17.15",
"memoize-one": "^5.0.5"
"memoize-one": "^6.0.0"
},
"devDependencies": {
"@cypress/code-coverage": "^3.10.0",
"@cypress/vue": "^3.1.0",
"@cypress/code-coverage": "^3.12.26",
"@cypress/vue": "^6.0.0",
"@istanbuljs/nyc-config-babel": "^3.0.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@storybook/addon-essentials": "^6.5.9",
"@storybook/addon-links": "^6.5.9",
"@storybook/builder-vite": "^0.1.38",
"@storybook/theming": "^6.5.9",
"@storybook/vue3": "^6.5.9",
"@vitejs/plugin-vue": "^2.3.3",
"@rollup/plugin-terser": "^0.4.4",
"@storybook/addon-essentials": "^7.6.17",
"@storybook/addon-links": "^7.6.17",
"@storybook/manager-api": "^7.6.17",
"@storybook/theming": "^7.6.17",
"@storybook/vue3": "^7.6.17",
"@storybook/vue3-vite": "^7.6.17",
"@vitejs/plugin-vue": "^5.0.4",
"@vue/compiler-sfc": "^3.2.37",
"@vue/server-test-utils": "^1.3.0",
"@vue/test-utils": "^2.0.0",
"cypress": "^10.3.0",
"@vue/test-utils": "^2.4.4",
"cypress": "^13.6.6",
"cypress-vite": "^1.5.0",
"git-url-parse": "^11.1.2",
"jsdom": "^14.0.0",
"happy-dom": "^13.6.2",
"nyc": "^15.1.0",
"prettier": "^2.1.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"sprintf-js": "^1.1.2",
"vite": "^2.9.13",
"vitest": "^0.16.0",
"vue": "^3.2.37"
"storybook": "^7.6.17",
"vite": "^5.1.4",
"vitest": "^1.3.1",
"vue": "^3.4.20"
},
"peerDependencies": {
"vue": "^3.0.0"
"vue": "^3.3.0"
},
"bugs": {
"url": "https://github.com/palerdot/vue-speedometer/issues"
},
"engines": {
"node": ">=8.0",
"npm": ">=3.0.0"
"node": ">=18.0",
"npm": ">=10.0.0"
},
"homepage": "https://github.com/palerdot/vue-speedometer#readme",
"keywords": [
Expand Down
Loading
Loading