-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
127 additions
and
36 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 |
---|---|---|
@@ -1,46 +1,33 @@ | ||
# Getting Started with Create React App | ||
# react-playground | ||
|
||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||
[![codecov](https://codecov.io/gh/kitsuyui/react-playground/branch/main/graph/badge.svg?token=6QX8OLRKAD)](https://codecov.io/gh/kitsuyui/react-playground) | ||
|
||
## Available Scripts | ||
|
||
In the project directory, you can run: | ||
## What is this? | ||
|
||
### `yarn start` | ||
This is a repository for practicing React. | ||
Create React components and check them with Storybook or write tests. | ||
It only deals with content that is closed to React. It does not handle Next.js, etc. | ||
For Next.js, see https://github.com/kitsuyui/nextjs-playground/ . | ||
|
||
Runs the app in the development mode.\ | ||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||
## Goal | ||
|
||
The page will reload if you make edits.\ | ||
You will also see any lint errors in the console. | ||
- [x] npm package of components | ||
- [x] Snapshot test of components | ||
- [x] Storybook of components | ||
- [x] Test coverage | ||
- [ ] Separation method that maintains the extensibility of styles | ||
|
||
### `yarn test` | ||
## Features | ||
|
||
Launches the test runner in the interactive watch mode.\ | ||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||
- [x] `@kitsuyui/react-clock` ... [![npm version](https://badge.fury.io/js/@kitsuyui%2Freact-clock.svg)](https://badge.fury.io/js/@kitsuyui%2Freact-clock) | ||
https://www.npmjs.com/package/@kitsuyui/react-clock | ||
- [x] `@kitsuyui/react-timer` ... [![npm version](https://badge.fury.io/js/@kitsuyui%2Freact-timer.svg)](https://badge.fury.io/js/@kitsuyui%2Freact-timer) | ||
https://www.npmjs.com/package/@kitsuyui/react-timer | ||
- [ ] Stopwatch | ||
- [ ] Alarm | ||
- [ ] Dice | ||
|
||
### `yarn build` | ||
## License | ||
|
||
Builds the app for production to the `build` folder.\ | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
The build is minified and the filenames include the hashes.\ | ||
Your app is ready to be deployed! | ||
|
||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||
|
||
### `yarn eject` | ||
|
||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||
|
||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||
|
||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||
|
||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||
|
||
## Learn More | ||
|
||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||
|
||
To learn React, check out the [React documentation](https://reactjs.org/). | ||
MIT |
File renamed without changes.
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,49 @@ | ||
# @kitsuyui/react-clock | ||
|
||
[![npm version](https://badge.fury.io/js/@kitsuyui%2Freact-clock.svg)](https://badge.fury.io/js/@kitsuyui%2Freact-clock) | ||
|
||
## Installation | ||
|
||
### npm | ||
|
||
```sh | ||
npm install @kitsuyui/react-clock | ||
``` | ||
|
||
### yarn | ||
|
||
```sh | ||
yarn add @kitsuyui/react-clock | ||
``` | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { ClockContainer, AnalogClock, DigitalClock } from '@kitsuyui/react-clock'; | ||
|
||
const Clock = () => { | ||
return ( | ||
<ClockContainer> | ||
<DateContext.Consumer> | ||
{(date: Date) => ( | ||
<> | ||
<AnalogClock timezone="Asia/Tokyo" date={date} /> | ||
<DigitalClock timezone="America/New_York" date={date} /> | ||
</> | ||
)} | ||
</DateContext.Consumer> | ||
</ClockContainer> | ||
) | ||
} | ||
``` | ||
|
||
ClockContainer is a component that provides DateContext. | ||
Clocks are pure components that do not depend on DateContext. Only the date and timezone are passed as props. | ||
So you can define your own Timer component by same interface. | ||
|
||
```typescript | ||
export interface ClockProps { | ||
timezone: string | ||
date: Date | ||
} | ||
``` |
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,55 @@ | ||
# @kitsuyui/react-timer | ||
|
||
[![npm version](https://badge.fury.io/js/@kitsuyui%2Freact-timer.svg)](https://badge.fury.io/js/@kitsuyui%2Freact-timer) | ||
|
||
## Installation | ||
|
||
### npm | ||
|
||
```sh | ||
npm install @kitsuyui/react-timer | ||
``` | ||
|
||
### yarn | ||
|
||
```sh | ||
yarn add @kitsuyui/react-timer | ||
``` | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { TimerContainer, MinimalTimer } from '@kitsuyui/react-timer'; | ||
|
||
const Timer = () => { | ||
return ( | ||
<TimerContainer> | ||
<TimerContext.Consumer> | ||
{(timer: TimerProps) => <MinimalTimer {...timer} />} | ||
</TimerContext.Consumer> | ||
</TimerContainer> | ||
) | ||
} | ||
``` | ||
|
||
TimerContainer is a component that provides TimerContext. | ||
Timers are pure components that do not depend on TimerContext. Accept TimerProps as props. | ||
So you can define your own Timer component by same interface. | ||
|
||
```typescript | ||
export interface TimerValue { | ||
remaining: number | ||
running: boolean | ||
} | ||
|
||
export interface TimerActions { | ||
start(): void | ||
stop(): void | ||
toggle(): void | ||
reset(): void | ||
incrementTimerValue(value: number): void | ||
setTimerValue(value: number): void | ||
} | ||
|
||
export type TimerProps = TimerValue & TimerActions | ||
``` |