-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added InstitutionsList ststic component
Added component Small changes to InstitutionContainer
- Loading branch information
Showing
16 changed files
with
241 additions
and
64 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,4 @@ | ||
<meta | ||
name="viewport" | ||
content="width=device-width,initial-scale=1,interactive-widget=resizes-content" | ||
/> |
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,23 @@ | ||
"use client"; | ||
|
||
import { useLayoutEffect, useState } from "react"; | ||
|
||
export function useVisualViewportSize() { | ||
// TODO make more abstracted logic, which can distinguish between mobile device and tabs | ||
const [visualViewport, setVisualViewport] = useState([0, 0]); | ||
useLayoutEffect(() => { | ||
function updateVisualViewportSize() { | ||
setVisualViewport({ | ||
width: window.visualViewport.width, | ||
height: window.visualViewport.height, | ||
}); | ||
} | ||
window.visualViewport.addEventListener("resize", () => | ||
setTimeout(updateVisualViewportSize, 200) | ||
); | ||
updateVisualViewportSize(); | ||
return () => window.removeEventListener("resize", updateVisualViewportSize); | ||
}, []); | ||
|
||
return visualViewport; | ||
} |
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
2 changes: 1 addition & 1 deletion
2
components/InstitutionContainer/InstitutionContainer.stories.jsx
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 @@ | ||
export { InstitutionContainer } from "./InstitutionContainer"; |
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,4 @@ | ||
export const institutionsListStyle = { | ||
display: "flex", | ||
flexDirection: "column", | ||
}; |
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,50 @@ | ||
"use client"; | ||
|
||
import { InstitutionsTabsList } from "../InstitutionsTabsList"; | ||
import { InstitutionContainer } from "../InstitutionContainer"; | ||
import { Tabs, TabPanels, TabPanel } from "@chakra-ui/react"; | ||
import { useVisualViewportSize } from "../../app/hooks"; | ||
import classes from "./InstitutionsList.module.css"; | ||
|
||
function InstitutionsList({ | ||
institutions, | ||
isExpanded, | ||
simulateKeyboard = false, | ||
}) { | ||
const { height } = useVisualViewportSize(); | ||
const isKeyboardOpened = simulateKeyboard || height < 650; | ||
|
||
return ( | ||
<Tabs | ||
// className={classes.institutionsList} | ||
h={isKeyboardOpened && height} | ||
// display="flex" | ||
// flexDir="column" | ||
variant="grid" | ||
padding={isExpanded || 2} | ||
> | ||
<TabPanels flexGrow={isKeyboardOpened && 1} flexShrink={1} minH="200px"> | ||
{institutions.map((institution, index) => ( | ||
<TabPanel | ||
p={0} | ||
key={"tab-panel-" + index} | ||
h={isKeyboardOpened ? "100%" : "230px"} | ||
> | ||
<InstitutionContainer | ||
isExpanded={isExpanded} | ||
institution={institution} | ||
/> | ||
</TabPanel> | ||
))} | ||
</TabPanels> | ||
{isExpanded || ( | ||
<InstitutionsTabsList | ||
simulateKeyboard={isKeyboardOpened} | ||
institutions={institutions} | ||
/> | ||
)} | ||
</Tabs> | ||
); | ||
} | ||
|
||
export { InstitutionsList }; |
Empty file.
100 changes: 100 additions & 0 deletions
100
components/InstitutionsList/InstitutionsList.stories.jsx
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,100 @@ | ||
import { InstitutionsList } from "./InstitutionsList"; | ||
|
||
const meta = { | ||
title: "RecordForm/InstitutionsList", | ||
component: InstitutionsList, | ||
}; | ||
export default meta; | ||
|
||
export const Default = { | ||
args: { | ||
simulateKeyboard: false, | ||
isExpanded: false, | ||
institutions: [ | ||
{ | ||
name: "City Bank", | ||
country: "it", | ||
assets: [ | ||
{ | ||
amount: 10000, | ||
currency: "usd", | ||
isEarning: false, | ||
description: "My Visa debit card", | ||
}, | ||
{ | ||
amount: 300000, | ||
currency: "eur", | ||
isEarning: true, | ||
description: "My Deposit", | ||
}, | ||
{ | ||
amount: 1000, | ||
currency: "cny", | ||
isEarning: true, | ||
description: "", | ||
}, | ||
{ | ||
amount: 5000, | ||
currency: "chf", | ||
isEarning: false, | ||
description: "", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "Wells & Fargo", | ||
country: "", | ||
assets: [ | ||
{ | ||
amount: 6443, | ||
currency: "brl", | ||
isEarning: false, | ||
description: "Debit card", | ||
}, | ||
{ | ||
amount: 8765, | ||
currency: "eur", | ||
isEarning: true, | ||
description: "My Deposit", | ||
}, | ||
{ | ||
amount: 1234, | ||
currency: "cny", | ||
isEarning: true, | ||
description: "", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "Bank Of America", | ||
country: "", | ||
assets: [ | ||
{ | ||
amount: 1700, | ||
currency: "usd", | ||
isEarning: false, | ||
description: "My Visa debit card", | ||
}, | ||
{ | ||
amount: 376000, | ||
currency: "usd", | ||
isEarning: true, | ||
description: "My Deposit", | ||
}, | ||
], | ||
}, | ||
{ | ||
name: "Raiffeisen Bank", | ||
country: "", | ||
assets: [ | ||
{ | ||
amount: 888, | ||
currency: "usd", | ||
isEarning: false, | ||
description: "My Visa debit card", | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; |
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,2 @@ | ||
export { InstitutionsList } from "./InstitutionsList"; | ||
export { institutionsListStyle } from "./InstitutionList.chakra"; |
3 changes: 0 additions & 3 deletions
3
components/InstitutionsTabsList/InstitutionTabsList.chakra.js
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
components/InstitutionsTabsList/InstitutionsTabsList.chakra.js
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,3 @@ | ||
export const institutionsTabsListStyle = { | ||
display: "grid", | ||
}; |
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
7 changes: 5 additions & 2 deletions
7
components/InstitutionsTabsList/InstitutionsTabsList.stories.jsx
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.