-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { observer } from "mobx-react-lite"; | ||
import { css, cx } from "@emotion/css"; | ||
import { reset } from "../../ui/reset.ts"; | ||
import { theme } from "../../ui/theme.tsx"; | ||
import { deckListStore } from "../../store/deck-list-store.ts"; | ||
import { ChevronIcon } from "../../ui/chevron-icon.tsx"; | ||
import React from "react"; | ||
|
||
export const ViewMoreDecksToggle = observer(() => { | ||
return ( | ||
<button | ||
className={cx( | ||
reset.button, | ||
css({ | ||
position: "absolute", | ||
right: 12, | ||
top: 2, | ||
color: theme.linkColor, | ||
fontSize: 14, | ||
textTransform: "uppercase", | ||
display: "flex", | ||
alignItems: "center", | ||
gap: 4, | ||
}), | ||
)} | ||
onClick={deckListStore.isMyDecksExpanded.toggle} | ||
> | ||
<span className={css({ transform: "translateY(2px)" })}> | ||
<ChevronIcon | ||
direction={deckListStore.isMyDecksExpanded.value ? "top" : "bottom"} | ||
/> | ||
</span> | ||
{deckListStore.isMyDecksExpanded.value ? "Hide" : "Show all"} | ||
</button> | ||
); | ||
}); |
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,43 @@ | ||
import { motion } from "framer-motion"; | ||
import React, { SVGProps } from "react"; | ||
|
||
type Direction = "top" | "bottom"; | ||
|
||
const getRotation = (direction: Direction) => { | ||
switch (direction) { | ||
case "top": | ||
return 0; | ||
case "bottom": | ||
return 180; | ||
} | ||
}; | ||
|
||
type Props = Pick<SVGProps<SVGSVGElement>, "onClick" | "className"> & { | ||
direction: Direction; | ||
}; | ||
|
||
export const ChevronIcon = (props: Props) => { | ||
const { direction, ...restProps } = props; | ||
return ( | ||
<motion.svg | ||
width="16" | ||
height="16" | ||
viewBox="0 0 16 16" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
whileTap={{ scale: 0.9 }} | ||
animate={{ rotate: getRotation(direction) }} | ||
initial={false} | ||
{...restProps} | ||
> | ||
<path | ||
d="M4 10.5L8.5 6L13 10.5" | ||
stroke="currentColor" | ||
strokeWidth="2" | ||
strokeMiterlimit="10" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
</motion.svg> | ||
); | ||
}; |
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