Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
694545a
refactor(vite): moving to d3 micro modules
palerdot Apr 3, 2022
5210236
refactor: set sideeffects false
palerdot Apr 3, 2022
0e5cdcf
test(vitest): moving to vitest
palerdot Apr 3, 2022
8510321
progress: basic vite prod build config
palerdot Apr 8, 2022
52e4c6a
progress: build enhancements
palerdot Apr 9, 2022
9493c6a
progress: storybook with vite
palerdot Apr 9, 2022
4858a9f
feat: slim build without bundling d3
palerdot Apr 9, 2022
962788d
test(cypress): initing cypress
palerdot Apr 10, 2022
312a732
test(cypress): more cypress tests
palerdot Apr 10, 2022
ea00e54
test(rtl): porting tests to React Testing Library
palerdot Apr 10, 2022
cc1a9b4
test(RTL): switching completely to RTL
palerdot Apr 10, 2022
2d9914d
chore(coverage): fix coverage
palerdot Apr 11, 2022
fe57fd2
chore(actions): force install dependencies ignoring peer dependencies…
palerdot Apr 11, 2022
fb45f46
docs(README): Slim build information
palerdot Apr 11, 2022
afa6a67
chore(actions): fix cypress actions
palerdot Apr 11, 2022
d203b48
chore(actions): codecov actions v2
palerdot Apr 11, 2022
7cfccc4
2.0.0-rc.0
palerdot Apr 11, 2022
89ea38e
fix(package.json): main refers to es build
palerdot Apr 11, 2022
9880c39
2.0.0-rc.1
palerdot Apr 11, 2022
391c9f5
fix(package.json): explicitly add types field to prevent TS errors
palerdot Apr 11, 2022
922e369
2.0.0-rc.2
palerdot Apr 11, 2022
0a8fb2e
fix(d3): better transition configuration
palerdot Apr 13, 2022
6c23d2d
chore(package.json): exports for slim build
palerdot Apr 13, 2022
7513b07
chore(package.json): prepublish build script
palerdot Apr 13, 2022
0f7c376
2.0.0-rc.3
palerdot Apr 13, 2022
1bccfda
chore(package.json): prepublishOnly build script
palerdot Apr 13, 2022
cea7b49
upgrade storybook
palerdot Sep 28, 2022
90562d4
feat: segmentValueFormatter function prop
palerdot Sep 28, 2022
929b661
add custom theme
palerdot Sep 28, 2022
33d5dae
fix theming brand title
palerdot Sep 28, 2022
d9ec6e1
2.1.0-rc.0
palerdot Sep 29, 2022
8001c01
docs: CHANGELOG
palerdot Sep 29, 2022
eb613b8
vite: externalize window for rollup
palerdot Sep 29, 2022
d71095f
vite: externalize window for rollup
palerdot Sep 29, 2022
31cbe60
remove explicit webpack 5 dependency
palerdot Sep 29, 2022
08a9aa1
docs: link rc npm badge
palerdot Feb 23, 2023
f3815b7
setup: switching to pnpm
palerdot Feb 23, 2023
02b7582
docs: link gif with relative path as github raw files are timing out
palerdot Feb 23, 2023
d3078aa
storybook: fix pnpm issue with hoisting
palerdot Feb 23, 2023
5922659
Merge branch 'master' into react-v18
palerdot Feb 23, 2023
902d39a
migrate cypress v12
palerdot Feb 23, 2023
56a5ea2
test: fixes dom queries for happy dom
palerdot Feb 23, 2023
f92e5b4
fix async svg errors
palerdot Feb 23, 2023
907cae7
add missing vitest coverage dev dep
palerdot Feb 23, 2023
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
17 changes: 13 additions & 4 deletions .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: [12.x]
node-version: [16.x]

steps:
- name: Checkout repository
Expand All @@ -24,11 +24,20 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

# we are using --force so that mismatching peer dependencies is ignored
- name: Install dependencies
run: npm install
run: yarn

# ref: https://github.com/cypress-io/github-action
- name: Setup cypress
uses: cypress-io/github-action@v2
with:
runTests: false
browser: chrome
headless: true

- name: Run the tests and generate coverage report
run: npm run testonly -- --coverage
run: yarn full-test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1.0.13
uses: codecov/codecov-action@v2
27 changes: 0 additions & 27 deletions .scripts/prepublish.sh

This file was deleted.

1 change: 0 additions & 1 deletion .scripts/user/prepublish.sh

This file was deleted.

1 change: 0 additions & 1 deletion .scripts/user/pretest.js

This file was deleted.

6 changes: 0 additions & 6 deletions .storybook/babel.config.js

This file was deleted.

44 changes: 30 additions & 14 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
// ref: https://github.com/storybookjs/builder-vite/blob/main/examples/react-18/.storybook/main.js
const { mergeConfig } = require('vite')

module.exports = {
stories: [
"../**/*.stories.js",
// "../src/stories/index.js"
],
addons: [
// "@storybook/addon-knobs/register",
"@storybook/addon-storysource",
{
name: "@storybook/addon-docs",
options: {
configureJSX: true,
babelOptions: {},
sourceLoaderOptions: null,
features: {
storyStoreV7: true,
},
async viteFinal(config, { configType }) {
// customize the Vite config here
// https://github.com/storybookjs/builder-vite/issues/237#issuecomment-1047819614
const { dirname } = require('path')
// https://github.com/eirslett/storybook-builder-vite/issues/55
config.root = dirname(require.resolve('@storybook/builder-vite'))

return mergeConfig(config, {
define: {
...config.define,
global: 'window',
},
},
})
},
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
// '@storybook/addon-links',
'@storybook/addon-essentials',
// '@storybook/addon-interactions',
],
framework: '@storybook/react',
core: {
builder: '@storybook/builder-vite',
// ref: https://storybook.js.org/docs/react/configure/telemetry
disableTelemetry: true, // 👈 Disables telemetry
},
}
15 changes: 12 additions & 3 deletions .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { addons } from "@storybook/addons"
import { themes } from "@storybook/theming"
import { addons } from '@storybook/addons'
import { themes, create } from '@storybook/theming'

import speedoTheme from '../src/core/theme'

const theme = create(speedoTheme)
const finalTheme = {
...themes.dark,
...theme,
}

addons.setConfig({
showPanel: true,
theme: themes.dark,
// theme: themes.dark,
theme: finalTheme,
})
3 changes: 3 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script>
window.global = window;
</script>
27 changes: 2 additions & 25 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
import { addParameters } from "@storybook/react"
import { create } from "@storybook/theming/create"
import theme from "../src/core/theme/"
import theme from '../src/core/theme/'

const speedoTheme = create({
...theme,
// appContentBg: "#413c69",

brandTitle: "react-d3-speedometer",
brandUrl: "https://github.com/palerdot/react-d3-speedometer",
})

addParameters({
options: {
/**
* display the top-level grouping as a "root" in the sidebar
* @type {Boolean}
*/
showPanel: true,
showRoots: true,
theme: speedoTheme,
},
docs: {
previewSource: "open",
},
})
export const parameters = {}
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Change Log

## 1.1.0
- `segmentValueFormatter` prop for customizing segment values.
## 2.1.0-rc.0 (`next`, `React 18`)
- `segmentValueFormatter` function prop for customizing segment values.

## 1.0.2
- `svgAriaLabel` prop for accessibility. More details - https://github.com/palerdot/react-d3-speedometer/issues/135
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

> React library for showing speedometer like gauge using d3.

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

![react-d3-speedometer](./speedo.gif)

[![CircleCI Build Status](https://circleci.com/gh/palerdot/react-d3-speedometer.svg?style=svg)](https://circleci.com/gh/palerdot/react-d3-speedometer)
[![Codecov](https://img.shields.io/codecov/c/gh/palerdot/react-d3-speedometer)](https://codecov.io/gh/palerdot/react-d3-speedometer)
[![npm](https://img.shields.io/npm/v/react-d3-speedometer)](https://www.npmjs.com/package/react-d3-speedometer)
[![npm](https://img.shields.io/npm/v/react-d3-speedometer/next?style=flat-square)](https://www.npmjs.com/package/react-d3-speedometer)
[![npm](https://img.shields.io/npm/dt/react-d3-speedometer.svg)](https://www.npmjs.com/package/react-d3-speedometer)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)


**Note**: `v1.x` is compatible with `React 17`. Please use latest `v0.x` (`v0.14.1` at the time of writing) if you are using `React 16`.
**Note**: `v2.x` is compatible with `React v18`. `v1.x` is compatible with `React 17`. Please use latest `v0.x` (`v0.14.1` at the time of writing) if you are using `React 16`.

[![NPM](https://nodei.co/npm/react-d3-speedometer.png)](https://npmjs.org/package/react-d3-speedometer)

Expand Down Expand Up @@ -48,6 +49,16 @@ import ReactSpeedometer from "react-d3-speedometer"
<ReactSpeedometer />
```

### Slim Build:

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 ReactSpeedometer from "react-d3-speedometer/slim"
// and use it
<ReactSpeedometer />
```

[Live Examples](https://palerdot.in/react-d3-speedometer)

## Configuration Options:
Expand Down
43 changes: 0 additions & 43 deletions babel.config.js

This file was deleted.

20 changes: 20 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { defineConfig } from "cypress";

export default defineConfig({
video: false,

component: {
setupNodeEvents(on, config) {},
specPattern: "src/__tests__/**/*.spec.js*",
devServer: {
framework: "react",
bundler: "vite",
},
},

e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
5 changes: 5 additions & 0 deletions cypress/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io",
"body": "Fixtures are a great way to mock data for responses to routes"
}
33 changes: 33 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/// <reference types="cypress" />
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************

// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)

// ref: https://docs.cypress.io/guides/component-testing/framework-configuration#Vite-Based-Projects-Vue-React
const path = require('path')
const { startDevServer } = require('@cypress/vite-dev-server')

/**
* @type {Cypress.PluginConfig}
*/

// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
on('dev-server:start', options => {
return startDevServer({
options,
viteConfig: {
configFile: path.resolve(__dirname, '..', '..', 'vite.config.js'),
},
})
})
}
25 changes: 25 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
37 changes: 37 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
//
//
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
//
// -- This is a child command --
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
//
// declare global {
// namespace Cypress {
// interface Chainable {
// login(email: string, password: string): Chainable<void>
// drag(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// dismiss(subject: string, options?: Partial<TypeOptions>): Chainable<Element>
// visit(originalFn: CommandOriginalFn, url: string, options: Partial<VisitOptions>): Chainable<Element>
// }
// }
// }
Loading