Skip to content

Commit

Permalink
Merge pull request #27 from Kuechlin/SegmentedControlBooleanFilter
Browse files Browse the repository at this point in the history
Segmented control for boolean filter
  • Loading branch information
Kuechlin authored Jul 27, 2022
2 parents d4f9c08 + 653d861 commit cc413d1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/github-actions-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
- name: checkout
uses: actions/[email protected]
- name: Install and Build 🔧
- name: install and build
run: |
npm i -g pnpm
pnpm i
pnpm run build
- run: pnpm publish --no-git-checks --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- name: publish
run: pnpm publish --no-git-checks --access public
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mantine-data-grid",
"version": "0.0.8",
"version": "0.0.9",
"license": "MIT",
"type": "module",
"repository": {
Expand Down
32 changes: 18 additions & 14 deletions src/filters/booleanFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Group, Radio } from '@mantine/core';
import { SegmentedControl } from '@mantine/core';
import { DataGridFilterFn, DataGridFilterProps } from '../types';

export enum BooleanFilter {
Expand Down Expand Up @@ -31,20 +31,24 @@ booleanFilterFn.element = function ({
filter,
onFilterChange,
}: DataGridFilterProps) {
const handleValueChange = (value: boolean) => () =>
onFilterChange({ ...filter, value });
const handleValueChange = (value: string) =>
onFilterChange({ ...filter, value: value === 'true' ? true : false });

return (
<Button.Group>
{[true, false].map((value) => (
<Button
key={String(value)}
color={filter.value === value ? 'blue' : 'gray'}
style={{ flexGrow: 1 }}
children={String(value)}
onClick={handleValueChange(value)}
/>
))}
</Button.Group>
<SegmentedControl
value={filter.value ? 'true' : 'false'}
onChange={handleValueChange}
data={[
{ label: 'true', value: 'true' },
{ label: 'false', value: 'false' },
]}
fullWidth
styles={{
active: {
// fix visual bug when opening filter dropdown
height: 'calc(100% - 8px) !important',
},
}}
/>
);
};

0 comments on commit cc413d1

Please sign in to comment.