-
-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[react] Create Stack component #118
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
82d60c7
[react] Create Stack component
brijeshb42 c4bbc46
Add Stack demo to both the apps
brijeshb42 1fa600f
Re-export RtlProvider from system
brijeshb42 3f9cfcd
Add proptypes
brijeshb42 06767d9
Refactor atomics implementation and add tests
brijeshb42 52fa495
Fix
brijeshb42 cae30fc
test fix
brijeshb42 5e9a05e
unrelated change
siriwatknp ff1ef61
simplify atomics
siriwatknp 1918b38
update next-app
siriwatknp b8e2df0
move css up
siriwatknp e340800
use css object
siriwatknp 1afa0d9
remove outdated types
siriwatknp 20b5bae
fix demo
siriwatknp 17deb66
fix object as a value with test cases
siriwatknp bfd1207
Include pigment-css react pkg in transform lib list
brijeshb42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import Image from 'next/image'; | ||
import { styled, css } from '@pigment-css/react'; | ||
import Stack from '@pigment-css/react/Stack'; | ||
import Chip from '@mui/material/Chip'; | ||
import styles from './page.module.css'; | ||
|
||
|
@@ -112,6 +113,11 @@ export default function Home() { | |
}, | ||
}} | ||
> | ||
<Stack spacing={{ xs: 2, md: 3 }}> | ||
<div>Item1</div> | ||
<div>Item1</div> | ||
<div>Item1</div> | ||
</Stack> | ||
Comment on lines
+116
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
<p sx={{ boxShadow: '0 0 4px 0 rgba(0 0 0 / 0.12)' }}> | ||
Get started by editing | ||
<code className={styles.code}>src/app/page.tsx</code> | ||
|
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,102 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import Stack from '@pigment-css/react/Stack'; | ||
import { styled, css } from '@pigment-css/react'; | ||
|
||
type StackProps = React.ComponentProps<typeof Stack>; | ||
|
||
const labelClass = css({ | ||
padding: '0px 10px', | ||
}); | ||
|
||
const Card = styled.div` | ||
transition: box-shadow 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; | ||
border-radius: 4px; | ||
box-shadow: | ||
rgba(0, 0, 0, 0.2) 0px 2px 1px -1px, | ||
rgba(0, 0, 0, 0.14) 0px 1px 1px 0px, | ||
rgba(0, 0, 0, 0.12) 0px 1px 3px 0px; | ||
background-image: linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.05)); | ||
color: white; | ||
padding: 8px 16px; | ||
font-family: Roboto, Helvetica, Arial, sans-serif; | ||
font-weight: 400; | ||
font-size: 0.875rem; | ||
line-height: 1.43; | ||
letter-spacing: 0.01071em; | ||
background-color: rgb(26, 32, 39); | ||
`; | ||
|
||
export default function InteractiveStack() { | ||
const [direction, setDirection] = React.useState<StackProps['direction']>('column'); | ||
const [spacing, setSpacing] = React.useState<string | number>(2); | ||
|
||
const handleChange = React.useCallback((ev: React.ChangeEvent<HTMLInputElement>) => { | ||
switch (ev.target.name) { | ||
case 'direction': { | ||
setDirection(ev.target.value as StackProps['direction']); | ||
break; | ||
} | ||
case 'spacing': { | ||
setSpacing( | ||
ev.target.value.match(/^[0-9]+\.?[0-9]*$/) | ||
? parseFloat(ev.target.value) | ||
: ev.target.value, | ||
); | ||
break; | ||
} | ||
default: | ||
break; | ||
} | ||
}, []); | ||
|
||
const jsx = ` | ||
<Stack | ||
direction="${direction}" | ||
spacing=${typeof spacing === 'number' ? `{${spacing}}` : `"${spacing}"`} | ||
> | ||
`; | ||
|
||
return ( | ||
<Stack spacing={2} sx={{ flexGrow: 1, padding: 2 }}> | ||
<Stack direction="row" justifyContent="space-between" spacing={2}> | ||
<fieldset> | ||
<legend>Direction</legend> | ||
{['row', 'row-reverse', 'column', 'column-reverse'].map((item) => ( | ||
<label key={item} className={labelClass}> | ||
{item} | ||
<input | ||
type="radio" | ||
name="direction" | ||
value={item} | ||
checked={item === direction} | ||
onChange={handleChange} | ||
/> | ||
</label> | ||
))} | ||
</fieldset> | ||
<fieldset sx={{ mt: 1 }}> | ||
<legend>Spacing</legend> | ||
{[0, 0.5, 1, 2, 3, 4, 8, 12, '2rem'].map((item) => ( | ||
<label key={item} className={labelClass}> | ||
{item} | ||
<input | ||
type="radio" | ||
name="spacing" | ||
value={item} | ||
checked={item === spacing} | ||
onChange={handleChange} | ||
/> | ||
</label> | ||
))} | ||
</fieldset> | ||
</Stack> | ||
<Stack direction={direction} spacing={spacing}> | ||
{[0, 1, 2].map((value) => ( | ||
<Card key={value}>{`Item ${value + 1}`}</Card> | ||
))} | ||
</Stack> | ||
<textarea style={{ colorScheme: 'dark' }} value={jsx} readOnly rows={8} /> | ||
</Stack> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,6 +1,7 @@ | ||
{ | ||
"rules": { | ||
"import/prefer-default-export": "off", | ||
"react/react-in-jsx-scope": "off" | ||
} | ||
"react/react-in-jsx-scope": "off", | ||
"react/no-unknown-property": ["error", { "ignore": ["sx"] }], | ||
}, | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To prevent an error
Cannot redefine property toString
.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.
I'm not very familiar with the Pigment setup, why is this required in detail?
Is
displayName
no longer required?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.
I'm not sure why @brijeshb42 removes the
displayName
, but foroverrideContext
it's a workaround for an error related to MUI System to make the app runnable (I will open a separate issue to discuss the options).The setup is not related to Stack.