Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: TeamWertarbyte/material-ui-dots
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.0.0-pre.1
Choose a base ref
...
head repository: TeamWertarbyte/material-ui-dots
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 20 commits
  • 31 files changed
  • 4 contributors

Commits on Nov 5, 2017

  1. Copy the full SHA
    cd85d02 View commit details

Commits on May 12, 2018

  1. Update dependencies.

    leMaik committed May 12, 2018
    Copy the full SHA
    44c5e7a View commit details

Commits on May 13, 2018

  1. Copy the full SHA
    d730ebb View commit details

Commits on May 18, 2018

  1. Update to material-ui 1.0.0.

    leMaik committed May 18, 2018
    Copy the full SHA
    ed06345 View commit details
  2. Use babel-preset-env.

    leMaik committed May 18, 2018
    Copy the full SHA
    0697902 View commit details
  3. Update the readme.

    leMaik committed May 18, 2018
    Copy the full SHA
    ba495e9 View commit details
  4. Copy the full SHA
    cbfa8e4 View commit details
  5. 2.0.0

    leMaik committed May 18, 2018
    Copy the full SHA
    e389cc9 View commit details

Commits on Mar 5, 2020

  1. Copy the full SHA
    7796b29 View commit details
  2. Copy the full SHA
    f83f9e1 View commit details
  3. Copy the full SHA
    641df2d View commit details
  4. 2.0.1

    leMaik committed Mar 5, 2020
    Copy the full SHA
    050cb92 View commit details

Commits on Mar 6, 2020

  1. Create FUNDING.yml

    leMaik authored Mar 6, 2020
    Copy the full SHA
    ef0d97e View commit details

Commits on Sep 27, 2020

  1. Fix @material-ui/core dependency.

    Fixes #14
    leMaik committed Sep 27, 2020
    Copy the full SHA
    fb7d795 View commit details
  2. Update dependencies.

    leMaik committed Sep 27, 2020
    Copy the full SHA
    f023d19 View commit details
  3. Copy the full SHA
    ad0d38f View commit details
  4. 2.0.2

    leMaik committed Sep 27, 2020
    Copy the full SHA
    3daa872 View commit details

Commits on Sep 13, 2024

  1. feat: migrate to MUI v6

    BREAKING CHANGE: Requires MUI v5 or MUI V6
    saschb2b authored and leMaik committed Sep 13, 2024
    Copy the full SHA
    2d36e4c View commit details
  2. Copy the full SHA
    d0bbe3e View commit details
  3. Copy the full SHA
    8fab946 View commit details
Showing with 2,963 additions and 7,426 deletions.
  1. +0 −7 .babelrc
  2. +18 −0 .eslintrc.cjs
  3. +4 −0 .github/FUNDING.yml
  4. +33 −0 .github/workflows/pr.yml
  5. +29 −0 .github/workflows/release.yml
  6. +22 −3 .gitignore
  7. +3 −1 .npmignore
  8. +2 −0 .prettierignore
  9. +5 −0 .prettierrc
  10. +8 −0 .releaserc.json
  11. +0 −3 .travis.yml
  12. +2 −2 LICENSE
  13. +25 −25 README.md
  14. +13 −0 index.html
  15. +86 −0 lib/components/Dots/Dots.tsx
  16. +1 −0 lib/components/Dots/index.ts
  17. +1 −0 lib/material-ui-dots.ts
  18. +1 −0 lib/vite-env.d.ts
  19. +0 −6,822 package-lock.json
  20. +49 −56 package.json
  21. +22 −0 src/App.tsx
  22. +0 −106 src/Dots.js
  23. +0 −67 src/Dots.spec.js
  24. +0 −322 src/__snapshots__/Dots.spec.js.snap
  25. +9 −0 src/main.tsx
  26. +0 −8 test/jestsetup.js
  27. +0 −4 test/shim.js
  28. +5 −0 tsconfig-build.json
  29. +25 −0 tsconfig.json
  30. +28 −0 vite.config.ts
  31. +2,572 −0 yarn.lock
7 changes: 0 additions & 7 deletions .babelrc

This file was deleted.

18 changes: 18 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
4 changes: 4 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: [leMaik,saschb2b]
ko_fi: wertarbyte
33 changes: 33 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: 'Check PR'

on:
pull_request_target:
types:
- opened
- synchronize
- reopened

jobs:
check-code:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Lint code
run: yarn lint
- name: Build library code
run: yarn build
check-versioning:
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v3.4.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Create release'

on: [workflow_dispatch]

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org/'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Lint code
run: yarn lint
- name: Build library code
run: yarn build
- name: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
25 changes: 22 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
build
lib
coverage
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
4 changes: 3 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
**/*
node_modules

src/*
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
/dist
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"endOfLine": "auto"
}
8 changes: 8 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github",
"@semantic-release/npm"
]
}
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016-2017 Wertarbyte
Copyright (c) 2024 Wertarbyte and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
# Material-UI Dots

[![npm Package](https://img.shields.io/npm/v/material-ui-dots/next.svg)](https://www.npmjs.com/package/material-ui-dots)
[![Build Status](https://travis-ci.org/TeamWertarbyte/material-ui-dots.svg?branch=next)](https://travis-ci.org/TeamWertarbyte/material-ui-dots)
[![Coverage Status](https://coveralls.io/repos/github/TeamWertarbyte/material-ui-dots/badge.svg?branch=next)](https://coveralls.io/github/TeamWertarbyte/material-ui-dots?branch=next)
[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![npm Package](https://img.shields.io/npm/v/material-ui-dots.svg)](https://www.npmjs.com/package/material-ui-dots)

This component gives you animated pagination dots as seen in the [Material Design specs][material-specs] and in the quick settings menu of Android N. The dots were extracted from our [auto-rotating carousel][material-auto-rotating-carousel] component.

[material-specs]: https://material.io/guidelines/growth-communications/onboarding.html#onboarding-top-user-benefits
[material-specs]: https://material.io/design/communication/onboarding.html#top-user-benefits-model
[material-auto-rotating-carousel]: https://github.com/TeamWertarbyte/material-auto-rotating-carousel

## Installation
```shell
npm i --save material-ui-dots
yarn add material-ui-dots
```

## Usage

There is only a single `Dots` component which is to be used in controlled mode. The following example component will display five dots and select a dot when clicking on it.

```js
import React from 'react'
import Dots from 'material-ui-dots'

class Demo extends React.Component {
constructor (props) {
super(props)
this.state = { index: 0 }
}

render () {
return (
<Dots
index={this.state.index}
count={5}
onDotClick={(index) => this.setState({ index })}
/>
)
}
}
import * as React from 'react'
import { Dots } from 'material-ui-dots'
import { Box } from '@mui/material';

export const App: React.FC = () => {
const [index, setIndex] = React.useState<number>(0);

return (
<Box
sx={{
display: 'flex',
justifyContent: 'center',
backgroundColor: 'rgba(0, 0, 0, 0.5)',
borderRadius: 6,
pb: 0.5,
width: 200,
}}
>
<Dots index={index} count={5} onDotClick={(value) => setIndex(value)} />
</Box>
);
};
```

## License
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dots - React Material UI component</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
86 changes: 86 additions & 0 deletions lib/components/Dots/Dots.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import React, { useEffect, useState } from 'react';
import Paper from '@mui/material/Paper';
import Box from '@mui/material/Box';
import { SxProps, Theme } from '@mui/material/styles';

interface DotsProps {
count: number;
index: number;
sx?: SxProps<Theme>;
onDotClick?: (
index: number,
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
) => void;
}

export const Dots: React.FC<DotsProps> = ({ count, index, sx, onDotClick }) => {
const [previousIndex, setPreviousIndex] = useState<number>(index);

useEffect(() => {
if (index !== previousIndex) {
const timeout = setTimeout(() => {
setPreviousIndex(index);
}, 400);
return () => clearTimeout(timeout);
}
}, [index, previousIndex]);

const handleDotClick = (
dotIndex: number,
event: React.MouseEvent<HTMLDivElement, MouseEvent>,
) => {
if (onDotClick) {
onDotClick(dotIndex, event);
}
};

return (
<Box sx={{ width: count * 16, ...sx }}>
<Box sx={{ position: 'relative', padding: '20px 0 28px' }}>
{[...Array(count).keys()].map((i) => (
<Box
key={i}
sx={{
width: 8,
height: 8,
padding: 0.5,
position: 'absolute',
left: i * 16,
cursor: onDotClick ? 'pointer' : 'inherit',
}}
onClick={(event) => handleDotClick(i, event)}
>
<Paper
elevation={0}
sx={{
width: 8,
height: 8,
background: '#fff',
borderRadius: 4,
transition: 'all 400ms cubic-bezier(0.4, 0.0, 0.2, 1)',
opacity:
i >= Math.min(previousIndex, index) &&
i <= Math.max(previousIndex, index)
? 0
: 0.5,
}}
/>
</Box>
))}
<Paper
elevation={0}
sx={{
position: 'absolute',
marginTop: 0.5,
left: Math.min(previousIndex, index) * 16 + 4,
width: Math.abs(previousIndex - index) * 16 + 8,
height: 8,
background: '#fff',
borderRadius: 4,
transition: 'all 400ms cubic-bezier(0.4, 0.0, 0.2, 1)',
}}
/>
</Box>
</Box>
);
};
1 change: 1 addition & 0 deletions lib/components/Dots/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Dots.tsx';
1 change: 1 addition & 0 deletions lib/material-ui-dots.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './components/Dots';
1 change: 1 addition & 0 deletions lib/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
Loading