Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Commit

Permalink
docs: add simple docs for v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nurulakbaral committed Jan 10, 2023
1 parent 24961d5 commit f8598e6
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 32 deletions.
53 changes: 36 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

Resval stands for Responsive Values, which is a hook that can return a value based on the current breakpoint. This hook can also respond to the size of the window.

⚒️ For now, Resval is only available for React, and hopefully available for the DOM as well.

### Why?

⚛️ React Responsive Values (Combine with themes from UI Libs, such as MUI, Chakra-UI, etc)\
⚛️ React Responsive Values (Combine with themes from UI Libs, such as MUI, Chakra UI, etc)\
🐳 Full TypeScript Support!\
🤠 Arbitrary Breakpoints!
🤠 Arbitrary Breakpoints!\
⚡ Optimized Performance!

# Installation

Expand All @@ -27,23 +26,38 @@ $ npm i @resval/react-responsive-values
```jsx
import { createResponsiveValues } from '@resval/react-responsive-values'

const breakpoints = {
base: '0px',
xs: '320px',
sm: '576px',
md: '768px',
lg: '1080px',
xl: '1280px',
}

const useVx = createResponsiveValues({
breakpoints: { ...breakpoints },
breakpoints: {
base: '0px',
xs: '320px',
sm: '576px',
md: '768px',
lg: '1080px',
xl: '1280px',
},
media: 'min',
})

const useResval = () => {
return useVx({
fontSize: {
base: '12px',
md: '24px',
},
color: {
base: 'red',
'600px': 'blue',
lg: 'black',
},
isMobileView: {
base: true,
md: false,
},
})
}

export function Component() {
const fontSize = useVx({ base: '12px', md: '24px' })
const color = useVx({ base: 'red', '600px': 'blue', lg: 'black' })
const { fontSize, color } = useResval()
return (
<div>
<h1 style={{ fontSize, color }}>Hello World!</h1>
Expand All @@ -52,9 +66,14 @@ export function Component() {
}

export default function About() {
const isMobileView = useVx({ base: true, md: false })
const { isMobileView } = useResval()
return isMobileView ? <h3>Mobile View</h3> : <h1>Desktop View</h1>
}
```

# Contributing

# Story

- Better abstraction in v1.0 - [Read More](https://github.com/nurulakbaral/resval/pull/4)
- Rendering optimization in v1.0 - [Read More](https://github.com/nurulakbaral/resval/pull/5)
51 changes: 36 additions & 15 deletions packages/react-resval/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ Resval stands for Responsive Values, which is a hook that can return a value bas

### Why?

⚛️ React Responsive Values (Combine with themes from UI Libs, such as MUI, Chakra-UI, etc)\
⚛️ React Responsive Values (Combine with themes from UI Libs, such as MUI, Chakra UI, etc)\
🐳 Full TypeScript Support!\
🤠 Arbitrary Breakpoints!
🤠 Arbitrary Breakpoints!\
⚡ Optimized Performance!

# Installation

Expand All @@ -25,23 +26,38 @@ $ npm i @resval/react-responsive-values
```jsx
import { createResponsiveValues } from '@resval/react-responsive-values'

const breakpoints = {
base: '0px',
xs: '320px',
sm: '576px',
md: '768px',
lg: '1080px',
xl: '1280px',
}

const useVx = createResponsiveValues({
breakpoints: { ...breakpoints },
breakpoints: {
base: '0px',
xs: '320px',
sm: '576px',
md: '768px',
lg: '1080px',
xl: '1280px',
},
media: 'min',
})

const useResval = () => {
return useVx({
fontSize: {
base: '12px',
md: '24px',
},
color: {
base: 'red',
'600px': 'blue',
lg: 'black',
},
isMobileView: {
base: true,
md: false,
},
})
}

export function Component() {
const fontSize = useVx({ base: '12px', md: '24px' })
const color = useVx({ base: 'red', '600px': 'blue', lg: 'black' })
const { fontSize, color } = useResval()
return (
<div>
<h1 style={{ fontSize, color }}>Hello World!</h1>
Expand All @@ -50,9 +66,14 @@ export function Component() {
}

export default function About() {
const isMobileView = useVx({ base: true, md: false })
const { isMobileView } = useResval()
return isMobileView ? <h3>Mobile View</h3> : <h1>Desktop View</h1>
}
```

# Contributing

# Story

- Better abstraction in v1.0 - [Read More](https://github.com/nurulakbaral/resval/pull/4)
- Rendering optimization in v1.0 - [Read More](https://github.com/nurulakbaral/resval/pull/5)

0 comments on commit f8598e6

Please sign in to comment.