-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add dates plugin * fix lint warnings for dates plugin * types: make format optional * changelogs * fix: add ts-ignore on Input * replace format with locale for dates * update size-limit * uncomment react-datepicker.css * remove unnecessary handler on dates-plugin Co-authored-by: David Bismut <[email protected]>
- Loading branch information
1 parent
6d1781a
commit 14a5605
Showing
24 changed files
with
5,060 additions
and
6,855 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@leva-ui/plugin-dates': major | ||
--- | ||
|
||
feat: new date picker plugin |
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
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,30 @@ | ||
{ | ||
"name": "leva-plugin-dates", | ||
"version": "1.0.0", | ||
"keywords": [], | ||
"main": "src/index.jsx", | ||
"dependencies": { | ||
"@leva-ui/plugin-dates": "*", | ||
"leva": "*", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"react-scripts": "4.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^17.0.2", | ||
"@types/react-dom": "^17.0.1", | ||
"typescript": "^4.1.5" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
}, | ||
"browserslist": [ | ||
">0.2%", | ||
"not dead", | ||
"not ie <= 11", | ||
"not op_mini all" | ||
] | ||
} |
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,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is added to the | ||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>Leva Sandbox</title> | ||
</head> | ||
|
||
<body> | ||
<noscript> You need to enable JavaScript to run this app. </noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
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,15 @@ | ||
import React from 'react' | ||
import { date } from '@leva-ui/plugin-dates' | ||
import { useControls } from 'leva' | ||
|
||
export default function App() { | ||
const { birthday } = useControls({ | ||
birthday: date({ | ||
date: new Date(), | ||
locale: 'en-UK', | ||
inputFormat: 'dd.MM.yyyy', | ||
}), | ||
}) | ||
|
||
return <div className="App">{birthday.formattedDate}</div> | ||
} |
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,19 @@ | ||
body { | ||
font-family: system-ui, sans-serif; | ||
min-height: 100vh; | ||
background: linear-gradient(140deg, rgb(165, 142, 251), rgb(233, 191, 248)); | ||
margin: 0; | ||
} | ||
|
||
*, | ||
*:after, | ||
*:before { | ||
box-sizing: border-box; | ||
} | ||
|
||
pre { | ||
max-width: 720px; | ||
margin: 20px; | ||
padding: 20px; | ||
border: 10px solid black; | ||
} |
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,13 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom' | ||
import App from './App' | ||
|
||
import './index.css' | ||
|
||
const rootElement = document.getElementById('root') | ||
ReactDOM.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
rootElement | ||
) |
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
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 @@ | ||
# @leva-ui/plugin-dates |
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,19 @@ | ||
## Leva Plot | ||
|
||
### Installation | ||
|
||
```bash | ||
npm i @leva-ui/plugin-plot | ||
``` | ||
|
||
### Quick start | ||
|
||
```jsx | ||
import { useControls } from 'leva' | ||
import { plot } from '@leva-ui/plugin-plot' | ||
|
||
function MyComponent() { | ||
const { y } = useControls({ y: plot({ expression: 'cos(x)', graph: true, boundsX: [-10, 10], boundsY: [0, 100] }) }) | ||
return y(Math.PI) | ||
} | ||
``` |
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,26 @@ | ||
{ | ||
"name": "@leva-ui/plugin-dates", | ||
"version": "0.9.15", | ||
"main": "dist/leva-ui-plugin-dates.cjs.js", | ||
"module": "dist/leva-ui-plugin-dates.esm.js", | ||
"types": "dist/leva-ui-plugin-dates.cjs.d.ts", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pmndrs/leva.git", | ||
"directory": "packages/plugin-dates" | ||
}, | ||
"bugs": "https://github.com/pmndrs/leva/issues", | ||
"peerDependencies": { | ||
"@use-gesture/react": "^10.0.0", | ||
"leva": ">=0.9.15", | ||
"react": ">=16.8.0", | ||
"react-dom": ">=16.8.0" | ||
}, | ||
"dependencies": { | ||
"react-datepicker": "^4.8.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react-datepicker": "4.4.2" | ||
} | ||
} |
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,27 @@ | ||
import React from 'react' | ||
import { Story, Meta } from '@storybook/react' | ||
|
||
import Reset from '../../leva/stories/components/decorator-reset' | ||
import { useControls } from '../../leva/src' | ||
|
||
import { date } from './index' | ||
import { DateInput } from './date-types' | ||
|
||
export default { | ||
title: 'Plugins/Dates', | ||
decorators: [Reset], | ||
} as Meta | ||
|
||
const Template: Story<DateInput> = (args) => { | ||
const { birthday } = useControls({ birthday: date(args) }) | ||
return <div>{birthday.formattedDate}</div> | ||
} | ||
|
||
export const DefaultDate = Template.bind({}) | ||
DefaultDate.args = { date: new Date() } | ||
|
||
export const CustomLocale = Template.bind({}) | ||
CustomLocale.args = { date: new Date(), locale: 'en-US' } | ||
|
||
export const CustomInputFormat = Template.bind({}) | ||
CustomInputFormat.args = { date: new Date(), inputFormat: 'yyyy-MM-dd' } |
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,39 @@ | ||
import { Components, useInputContext } from 'leva/plugin' | ||
import React, { forwardRef } from 'react' | ||
import DatePicker, { CalendarContainer } from 'react-datepicker' | ||
import 'react-datepicker/dist/react-datepicker.css' | ||
import { DateCalendarContainerProps, DateInputProps, DateProps } from './date-types' | ||
import { InputContainer, StyledInput, StyledWrapper } from './StyledDate' | ||
|
||
const { Label, Row } = Components | ||
|
||
const DateCalendarContainer = ({ children }: DateCalendarContainerProps) => { | ||
return ( | ||
<CalendarContainer> | ||
<StyledWrapper>{children}</StyledWrapper> | ||
</CalendarContainer> | ||
) | ||
} | ||
|
||
const DateInput = forwardRef<HTMLInputElement, Partial<DateInputProps>>(({ value, onClick, onChange }, ref) => { | ||
return <StyledInput ref={ref} value={value} onClick={onClick} onChange={onChange} /> | ||
}) | ||
|
||
export function Date() { | ||
const { label, value, onUpdate, settings } = useInputContext<DateProps>() | ||
|
||
return ( | ||
<Row input> | ||
<Label>{label}</Label> | ||
<InputContainer> | ||
<DatePicker | ||
selected={value.date} | ||
onChange={onUpdate} | ||
dateFormat={settings.inputFormat} | ||
calendarContainer={DateCalendarContainer} | ||
customInput={<DateInput />} | ||
/> | ||
</InputContainer> | ||
</Row> | ||
) | ||
} |
Oops, something went wrong.
14a5605
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
leva – ./
leva-pmndrs.vercel.app
leva-git-main-pmndrs.vercel.app
leva.vercel.app
leva.pmnd.rs