Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@mantine/core] add controlled search and per-list wording to transfe…
…r-list
- Loading branch information
Jérémie van der Sande
committed
Oct 21, 2022
1 parent
eaeef08
commit 14ed785
Showing
7 changed files
with
201 additions
and
8 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
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
66 changes: 66 additions & 0 deletions
66
src/mantine-demos/src/demos/core/TransferList/TransferList.demo.controlledSearch.tsx
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,66 @@ | ||
import React, { useState } from 'react'; | ||
import { MantineDemo } from '@mantine/ds'; | ||
import { Stack, Text } from '@mantine/core'; | ||
import { Wrapper } from './_wrapper'; | ||
|
||
const code = ` | ||
import { useState } from 'react' | ||
import { TransferList, Stack, Text } from '@mantine/core'; | ||
function Demo() { | ||
const [search, setSearch] = useState(['', '']); | ||
return ( | ||
<Stack> | ||
<Text> | ||
<Text component="span" weight="bold">Left search: </Text> | ||
{search[0] || '---'} | ||
{' / '} | ||
<Text component="span" weight="bold">Right search: </Text> | ||
{search[1] || '---'} | ||
</Text> | ||
<TransferList | ||
searchValues={search} | ||
onSearch={setSearch} | ||
{/* ...other props */} | ||
/> | ||
</Stack> | ||
); | ||
} | ||
`; | ||
|
||
function Demo() { | ||
const [search, setSearch] = useState<[string, string]>(['', '']); | ||
|
||
return ( | ||
<Stack> | ||
<Text> | ||
<Text component="span" weight="bold"> | ||
Left search:{' '} | ||
</Text> | ||
{search[0] || '---'} | ||
{' / '} | ||
<Text component="span" weight="bold"> | ||
Right search:{' '} | ||
</Text> | ||
{search[1] || '---'} | ||
</Text> | ||
|
||
<Wrapper | ||
searchPlaceholder="Search..." | ||
nothingFound="Nothing here" | ||
titles={['Frameworks', 'Libraries']} | ||
breakpoint="sm" | ||
searchValues={search} | ||
onSearch={setSearch} | ||
/> | ||
</Stack> | ||
); | ||
} | ||
|
||
export const controlledSearch: MantineDemo = { | ||
type: 'demo', | ||
component: Demo, | ||
code, | ||
}; |
34 changes: 34 additions & 0 deletions
34
src/mantine-demos/src/demos/core/TransferList/TransferList.demo.differentPlaceholders.tsx
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,34 @@ | ||
import React from 'react'; | ||
import { MantineDemo } from '@mantine/ds'; | ||
import { Wrapper } from './_wrapper'; | ||
|
||
const code = ` | ||
function Demo() { | ||
return ( | ||
<TransferList | ||
searchPlaceholder={['Search item to add...', 'Search item to remove...']} | ||
nothingFound={['Cannot find item to add', 'Cannot find item to remove']} | ||
placeholder={['No item left to add', 'No item left ro remove']} | ||
{/* ...other props */} | ||
/> | ||
); | ||
} | ||
`; | ||
|
||
function Demo() { | ||
return ( | ||
<Wrapper | ||
searchPlaceholder={['Search item to add...', 'Search item to remove...']} | ||
nothingFound={['Cannot find item to add', 'Cannot find item to remove']} | ||
placeholder={['No item left to add', 'No item left ro remove']} | ||
titles={['Frameworks', 'Libraries']} | ||
breakpoint="sm" | ||
/> | ||
); | ||
} | ||
|
||
export const differentPlaceholders: MantineDemo = { | ||
type: 'demo', | ||
component: Demo, | ||
code, | ||
}; |
32 changes: 32 additions & 0 deletions
32
src/mantine-demos/src/demos/core/TransferList/TransferList.demo.placeholder.tsx
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,32 @@ | ||
import React from 'react'; | ||
import { MantineDemo } from '@mantine/ds'; | ||
import { Wrapper } from './_wrapper'; | ||
|
||
const code = ` | ||
function Demo() { | ||
return ( | ||
<TransferList | ||
nothingFound="Nothing found" | ||
placeholder="No item left" | ||
{/* ...other props */} | ||
/> | ||
); | ||
} | ||
`; | ||
|
||
function Demo() { | ||
return ( | ||
<Wrapper | ||
nothingFound="Nothing found" | ||
placeholder="No item left" | ||
titles={['Frameworks', 'Libraries']} | ||
breakpoint="sm" | ||
/> | ||
); | ||
} | ||
|
||
export const placeholder: MantineDemo = { | ||
type: 'demo', | ||
component: Demo, | ||
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