This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
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.
feat: add infinite scroll for project lists and datasets in dashboard…
… and setting pages (#225) * adding-avatar-system * pr-fixes * pr-fixes * refactored avatar component and styles * add space in member list * infinite-scroll * merge-with-main * merge-main * resolve-conflicts * resolve conflict2 * rc * fix-lists * fix-cli * gql-schema * fix-cli * fix-cli * f-c * Delete yarn-1.22.17.cjs * fixes * Update src/components/molecules/Settings/SettingPage/index.tsx Co-authored-by: KaWaite <34051327+KaWaite@users.noreply.github.com> * pr-comments-fix * F-c * i18n-queries * queries * Regen yarn-lock * refactor gql provider * Update package.json * remove modified yarn lock * project-list * project-list * Update src/components/molecules/Common/Header/index.tsx Co-authored-by: KaWaite <34051327+KaWaite@users.noreply.github.com> * Update src/components/molecules/Settings/SettingPage/index.tsx Co-authored-by: KaWaite <34051327+KaWaite@users.noreply.github.com> * Update src/components/organisms/Dashboard/hooks.ts Co-authored-by: KaWaite <34051327+KaWaite@users.noreply.github.com> * Update src/components/organisms/Dashboard/hooks.ts Co-authored-by: KaWaite <34051327+KaWaite@users.noreply.github.com> * Update src/components/organisms/Settings/ProjectList/hooks.ts Co-authored-by: KaWaite <34051327+KaWaite@users.noreply.github.com> * pr-fixing * refactor ProjectList component * pr-fixes2 * pr-fixes3 * pr-fixes4 * pr-fixes5 * update translation * remove old translations Co-authored-by: nina992 <nouralali992@gmail.com> Co-authored-by: KaWaite <kyle.waite@outlook.com> Co-authored-by: KaWaite <34051327+KaWaite@users.noreply.github.com> Co-authored-by: lby <icesunex@hotmail.com> Co-authored-by: rot1024 <aayhrot@gmail.com>
- Loading branch information
1 parent
99c378d
commit 28d377b
Showing
31 changed files
with
683 additions
and
255 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,4 +217,4 @@ | |
"use-debounce": "^7.0.1", | ||
"use-file-input": "^1.0.0" | ||
} | ||
} | ||
} |
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,106 @@ | ||
import React, { useEffect, useState } from "react"; | ||
|
||
import Text from "@reearth/components/atoms/Text"; | ||
import { styled, useTheme } from "@reearth/theme"; | ||
|
||
import Divider from "../Divider"; | ||
|
||
export type MenuAlignment = "left" | "top"; | ||
|
||
export interface Props<T extends string> { | ||
className?: string; | ||
children?: { [m in T]?: React.ReactNode }; | ||
headerAction?: React.ReactNode; | ||
menuAlignment?: MenuAlignment; | ||
scrollable?: boolean; | ||
expandedMenuIcon?: boolean; | ||
selected?: T; | ||
initialSelected?: T; | ||
onChange?: (m: T) => void; | ||
headers?: { [m in T]?: string }; | ||
} | ||
const TabSection = <T extends string>({ | ||
className, | ||
children, | ||
headerAction, | ||
menuAlignment, | ||
scrollable, | ||
selected, | ||
onChange, | ||
initialSelected, | ||
headers, | ||
}: Props<T>) => { | ||
const tabs: T[] = (Object.keys(children || {}) as T[]).filter(k => !!children?.[k]); | ||
const [selectedTab, select] = useState<T | undefined>(initialSelected ?? tabs?.[0]); | ||
useEffect(() => { | ||
select(selected); | ||
}, [selected]); | ||
|
||
const theme = useTheme(); | ||
|
||
return ( | ||
<Wrapper className={className} menuAlignment={menuAlignment}> | ||
<TabHeader> | ||
{tabs?.map((m: T) => ( | ||
<TabTitle | ||
key={m} | ||
selected={selectedTab === m} | ||
onClick={() => { | ||
select(m); | ||
onChange?.(m); | ||
}}> | ||
<Text size="m" color={selectedTab === m ? theme.main.select : theme.main.text}> | ||
{headers?.[m] ?? m} | ||
</Text> | ||
</TabTitle> | ||
))} | ||
{<ActionWrapper expanded={true}>{headerAction}</ActionWrapper>} | ||
</TabHeader> | ||
<Divider margin="0" /> | ||
<TabContent scrollable={scrollable}> | ||
{selectedTab ? children?.[selectedTab] ?? null : null} | ||
</TabContent> | ||
</Wrapper> | ||
); | ||
}; | ||
const Wrapper = styled.div<{ menuAlignment?: MenuAlignment }>` | ||
display: flex; | ||
flex-flow: ${({ menuAlignment }) => (menuAlignment === "top" ? "column" : "row")} nowrap; | ||
justify-content: stretch; | ||
position: relative; | ||
`; | ||
const TabHeader = styled.div<{ menuAlignment?: MenuAlignment }>` | ||
display: flex; | ||
flex-flow: ${({ menuAlignment }) => (menuAlignment === "top" ? "column" : "row")} nowrap; | ||
align-items: space-between; | ||
gap: 24px; | ||
padding: 0px; | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
const TabTitle = styled.div<{ selected?: boolean }>` | ||
cursor: pointer; | ||
user-select: none; | ||
border-bottom: 2px solid ${({ selected, theme }) => (selected ? theme.main.select : "none")}; | ||
opacity: ${({ selected }) => (selected ? "1" : "0.7")}; | ||
`; | ||
|
||
const ActionWrapper = styled.div<{ expanded?: boolean }>` | ||
flex: ${props => (props.expanded ? "1" : null)}; | ||
display: flex; | ||
flex-direction: row-reverse; | ||
align-items: flex-start; | ||
margin-block-start: -13px; | ||
`; | ||
const TabContent = styled.div<{ scrollable?: boolean }>` | ||
flex: auto; | ||
display: flex; | ||
flex-flow: column nowrap; | ||
justify-content: stretch; | ||
overflow-x: hidden; | ||
overflow-y: ${({ scrollable }) => (scrollable ? "auto" : "hidden")}; | ||
-webkit-overflow-scrolling: touch; | ||
`; | ||
|
||
export default TabSection; |
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
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
Oops, something went wrong.