-
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(window-group): reactive stacking + deferred layout (fixes #23, #24) #25
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
576 changes: 288 additions & 288 deletions
576
.yarn/releases/yarn-4.13.0.cjs → .yarn/releases/yarn-4.14.1.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,3 +1,3 @@ | ||
| nodeLinker: node-modules | ||
|
|
||
| yarnPath: .yarn/releases/yarn-4.13.0.cjs | ||
| yarnPath: .yarn/releases/yarn-4.14.1.cjs |
This file contains hidden or 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,88 @@ | ||
| import { useState } from 'react'; | ||
| import { Window } from '@gfazioli/mantine-window'; | ||
| import { Button, Group, Title } from '@mantine/core'; | ||
| import { MantineDemo } from '@mantinex/demo'; | ||
|
|
||
| const code = `import { useState } from 'react'; | ||
| import { Window } from '@gfazioli/mantine-window'; | ||
| import { Button, Group, Title } from '@mantine/core'; | ||
|
|
||
| function Demo() { | ||
| const [ids, setIds] = useState<string[]>(['alpha', 'beta']); | ||
|
|
||
| return ( | ||
| <> | ||
| <Group mb="md"> | ||
| <Button | ||
| onClick={() => | ||
| setIds((prev) => [...prev, String.fromCharCode(97 + prev.length)]) | ||
| } | ||
| > | ||
| Add window | ||
| </Button> | ||
| <Button color="red" onClick={() => setIds((prev) => prev.slice(0, -1))}> | ||
| Remove last | ||
| </Button> | ||
| </Group> | ||
| <Window.Group style={{ width: '100%', height: 500 }}> | ||
| {ids.map((id, i) => ( | ||
| <Window | ||
| id={\`win_\${id}\`} | ||
| key={\`win_\${id}\`} | ||
| title={\`Window \${id}\`} | ||
| opened | ||
| defaultX={20 + i * 40} | ||
| defaultY={20 + i * 40} | ||
| defaultWidth={300} | ||
| defaultHeight={200} | ||
| > | ||
| <Title order={4}>Dynamic {id}</Title> | ||
| <p>Click the green tools button to apply a layout preset.</p> | ||
| </Window> | ||
| ))} | ||
| </Window.Group> | ||
| </> | ||
| ); | ||
| } | ||
| `; | ||
|
|
||
| function Demo() { | ||
| const [ids, setIds] = useState<string[]>(['alpha', 'beta']); | ||
|
|
||
| return ( | ||
| <> | ||
| <Group mb="md"> | ||
| <Button onClick={() => setIds((prev) => [...prev, String.fromCharCode(97 + prev.length)])}> | ||
| Add window | ||
| </Button> | ||
| <Button color="red" onClick={() => setIds((prev) => prev.slice(0, -1))}> | ||
| Remove last | ||
| </Button> | ||
| </Group> | ||
| <Window.Group style={{ width: '100%', height: 500 }}> | ||
| {ids.map((id, i) => ( | ||
| <Window | ||
| id={`win_${id}`} | ||
| key={`win_${id}`} | ||
| title={`Window ${id}`} | ||
| opened | ||
| defaultX={20 + i * 40} | ||
| defaultY={20 + i * 40} | ||
| defaultWidth={300} | ||
| defaultHeight={200} | ||
| > | ||
| <Title order={4}>Dynamic {id}</Title> | ||
| <p>Click the green tools button to apply a layout preset.</p> | ||
| </Window> | ||
| ))} | ||
| </Window.Group> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export const dynamicWindows: MantineDemo = { | ||
| type: 'code', | ||
| component: Demo, | ||
| code, | ||
| defaultExpanded: false, | ||
| }; | ||
This file contains hidden or 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,118 @@ | ||
| import { useState } from 'react'; | ||
| import { Window } from '@gfazioli/mantine-window'; | ||
| import { SegmentedControl, Stack, Text, Title } from '@mantine/core'; | ||
| import { MantineDemo } from '@mantinex/demo'; | ||
|
|
||
| const code = `import { useState } from 'react'; | ||
| import { Window } from '@gfazioli/mantine-window'; | ||
| import { SegmentedControl, Stack, Text, Title } from '@mantine/core'; | ||
|
|
||
| function Demo() { | ||
| const [strategy, setStrategy] = useState<'increment' | 'normalize'>('normalize'); | ||
|
|
||
| return ( | ||
| <Stack> | ||
| <SegmentedControl | ||
| value={strategy} | ||
| onChange={(v) => setStrategy(v as 'increment' | 'normalize')} | ||
| data={[ | ||
| { label: 'increment (legacy)', value: 'increment' }, | ||
| { label: 'normalize', value: 'normalize' }, | ||
| ]} | ||
| /> | ||
| <Text size="sm" c="dimmed"> | ||
| Click each window in any order. With <code>normalize</code>, z-indexes always stay | ||
| compact ({'{100..102}'}). With <code>increment</code>, the counter keeps growing | ||
| unless <code>maxZIndex</code> is set. | ||
| </Text> | ||
| <Window.Group | ||
| key={strategy} | ||
| style={{ width: '100%', height: 500 }} | ||
| zIndexStrategy={strategy} | ||
| initialZIndex={100} | ||
| maxZIndex={strategy === 'increment' ? 105 : undefined} | ||
| > | ||
| <Window id="z1" title="Alpha" opened defaultX={20} defaultY={20} defaultWidth={260} defaultHeight={180}> | ||
| <Title order={5}>Alpha</Title> | ||
| </Window> | ||
| <Window id="z2" title="Beta" opened defaultX={80} defaultY={80} defaultWidth={260} defaultHeight={180}> | ||
| <Title order={5}>Beta</Title> | ||
| </Window> | ||
| <Window id="z3" title="Gamma" opened defaultX={140} defaultY={140} defaultWidth={260} defaultHeight={180}> | ||
| <Title order={5}>Gamma</Title> | ||
| </Window> | ||
| </Window.Group> | ||
| </Stack> | ||
| ); | ||
| } | ||
| `; | ||
|
|
||
| function Demo() { | ||
| const [strategy, setStrategy] = useState<'increment' | 'normalize'>('normalize'); | ||
|
|
||
| return ( | ||
| <Stack> | ||
| <SegmentedControl | ||
| value={strategy} | ||
| onChange={(v) => setStrategy(v as 'increment' | 'normalize')} | ||
| data={[ | ||
| { label: 'increment (legacy)', value: 'increment' }, | ||
| { label: 'normalize', value: 'normalize' }, | ||
| ]} | ||
| /> | ||
| <Text size="sm" c="dimmed"> | ||
| Click each window in any order. With <code>normalize</code>, z-indexes always stay compact ( | ||
| {'{100..102}'}). With <code>increment</code>, the counter keeps growing unless{' '} | ||
| <code>maxZIndex</code> is set. | ||
| </Text> | ||
| <Window.Group | ||
| key={strategy} | ||
| style={{ width: '100%', height: 500 }} | ||
| zIndexStrategy={strategy} | ||
| initialZIndex={100} | ||
| maxZIndex={strategy === 'increment' ? 105 : undefined} | ||
| > | ||
| <Window | ||
| id="z1" | ||
| title="Alpha" | ||
| opened | ||
| defaultX={20} | ||
| defaultY={20} | ||
| defaultWidth={260} | ||
| defaultHeight={180} | ||
| > | ||
| <Title order={5}>Alpha</Title> | ||
| </Window> | ||
| <Window | ||
| id="z2" | ||
| title="Beta" | ||
| opened | ||
| defaultX={80} | ||
| defaultY={80} | ||
| defaultWidth={260} | ||
| defaultHeight={180} | ||
| > | ||
| <Title order={5}>Beta</Title> | ||
| </Window> | ||
| <Window | ||
| id="z3" | ||
| title="Gamma" | ||
| opened | ||
| defaultX={140} | ||
| defaultY={140} | ||
| defaultWidth={260} | ||
| defaultHeight={180} | ||
| > | ||
| <Title order={5}>Gamma</Title> | ||
| </Window> | ||
| </Window.Group> | ||
| </Stack> | ||
| ); | ||
| } | ||
|
|
||
| export const zIndexStrategy: MantineDemo = { | ||
| type: 'code', | ||
| component: Demo, | ||
| code, | ||
| defaultExpanded: false, | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.