-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from UgnisSoftware/UGN-221
feat UGN-221 - add column matching
- Loading branch information
Showing
8 changed files
with
138 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createIcon } from "@chakra-ui/icon" | ||
import * as React from "react" | ||
|
||
export const CheckIcon = createIcon({ | ||
viewBox: "0 0 14 14", | ||
path: ( | ||
<g fill="currentColor"> | ||
<polygon points="5.5 11.9993304 14 3.49933039 12.5 2 5.5 8.99933039 1.5 4.9968652 0 6.49933039" /> | ||
</g> | ||
), | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { chakra, useStyleConfig, Flex } from "@chakra-ui/react" | ||
import { dataAttr } from "@chakra-ui/utils" | ||
import { motion } from "framer-motion" | ||
import { CheckIcon } from "./CheckIcon" | ||
|
||
const MotionFlex = motion(Flex) | ||
|
||
const animationConfig = { | ||
transition: { | ||
duration: 0.1, | ||
}, | ||
exit: { scale: 0.5, opacity: 0 }, | ||
initial: { scale: 0.5, opacity: 0 }, | ||
animate: { scale: 1, opacity: 1 }, | ||
} | ||
type MatchIconProps = { | ||
matched: boolean | ||
} | ||
|
||
export const MatchIcon = (props: MatchIconProps) => { | ||
const style = useStyleConfig("MatchIcon", props) | ||
return ( | ||
<chakra.div __css={style} minW={6} minH={6} w={6} h={6} data-highlighted={dataAttr(props.matched)} ml={'0.875rem'} mr={3}> | ||
{props.matched && ( | ||
<MotionFlex {...animationConfig}> | ||
<CheckIcon width={3} height={3} /> | ||
</MotionFlex> | ||
)} | ||
</chakra.div> | ||
) | ||
} |
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,29 @@ | ||
import type { Column } from "./MatchColumns" | ||
import { Flex, Select } from "@chakra-ui/react" | ||
import { useRsi } from "../hooks/useRsi" | ||
import { MatchIcon } from "./MatchIcon" | ||
|
||
const SELECT_PLACEHOLDER = "Select column..." | ||
|
||
type TemplateColumnProps = { | ||
onChange: (val: string, index: number) => void | ||
column: Column | ||
} | ||
|
||
export const TemplateColumn = ({ column, onChange }: TemplateColumnProps) => { | ||
const { fields } = useRsi() | ||
return ( | ||
<Flex alignItems='center'> | ||
<Select | ||
placeholder={SELECT_PLACEHOLDER} | ||
value={"value" in column ? column.value : undefined} | ||
onChange={(event) => onChange(event.target.value, column.index)} | ||
> | ||
{fields.map(({ label, key }) => ( | ||
<option value={key}>{label}</option> | ||
))} | ||
</Select> | ||
<MatchIcon matched={"value" in column ? !!column.value : false} /> | ||
</Flex> | ||
) | ||
} |
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
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