Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[@mantine/core] TransferList: Add
transferIcon
, transferAllIcon
p…
…rops, controlled search and tuple syntax for `seachPlaceholder` and `nothingFound` props (#2769) * [@mantine/core] add custom icons capability to transfer-list * [@mantine/core] add controlled search and per-list wording to transfer-list Co-authored-by: Jérémie van der Sande <jeremie.van-der-sande@ubisoft.com>
- Loading branch information
Showing
8 changed files
with
269 additions
and
11 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, | ||
}; |
43 changes: 43 additions & 0 deletions
43
src/mantine-demos/src/demos/core/TransferList/TransferList.demo.customIcons.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,43 @@ | ||
import React from 'react'; | ||
import { IconFilePlus, IconFolderPlus, IconFileMinus, IconFolderMinus } from '@tabler/icons'; | ||
import { MantineDemo } from '@mantine/ds'; | ||
import { Wrapper } from './_wrapper'; | ||
|
||
const code = ` | ||
import { | ||
IconFilePlus, | ||
IconFolderPlus, | ||
IconFileMinus, | ||
IconFolderMinus, | ||
} from '@tabler/icons'; | ||
import { TransferList } from '@mantine/core'; | ||
function Demo() { | ||
return ( | ||
<TransferList | ||
transferIcon={({ reversed }) => (reversed ? <IconFileMinus /> : <IconFilePlus />)} | ||
transferAllIcon={({ reversed }) => (reversed ? <IconFolderMinus /> : <IconFolderPlus />)} | ||
{/* ...other props */} | ||
/> | ||
) | ||
} | ||
`; | ||
|
||
function Demo() { | ||
return ( | ||
<Wrapper | ||
searchPlaceholder="Search..." | ||
nothingFound="Nothing here" | ||
titles={['Frameworks', 'Libraries']} | ||
breakpoint="sm" | ||
transferIcon={({ reversed }) => (reversed ? <IconFileMinus /> : <IconFilePlus />)} | ||
transferAllIcon={({ reversed }) => (reversed ? <IconFolderMinus /> : <IconFolderPlus />)} | ||
/> | ||
); | ||
} | ||
|
||
export const customIcons: MantineDemo = { | ||
type: 'demo', | ||
component: Demo, | ||
code, | ||
}; |
Oops, something went wrong.