-
Notifications
You must be signed in to change notification settings - Fork 0
Fix/vertical spacing #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/vertical spacing #160
Changes from all commits
cf7a7b7
459b2da
a938ba5
203214b
8310931
c1ca39a
628c093
92d558d
524fc37
19abf91
9b71b89
9335fc8
bcf948c
58b0902
cbcc139
b6378ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,61 @@ | ||||||
| import { Typography } from "antd"; | ||||||
| import { ArrowDownOutlined, ArrowUpOutlined } from "@ant-design/icons"; | ||||||
| import { useEffect, useLayoutEffect, useRef, useState } from "react"; | ||||||
| import { | ||||||
| DEFAULT_DESCRIPTION_HEIGHT, | ||||||
| TEXT_BOTTOM_MARGIN, | ||||||
| } from "../../constants"; | ||||||
|
|
||||||
| import "./style.css"; | ||||||
| const { Paragraph } = Typography; | ||||||
|
|
||||||
| interface ExpandableTextProps { | ||||||
| text: string; | ||||||
| setCurrentHeight: (height: number) => void; | ||||||
| } | ||||||
|
|
||||||
| const expandSymbol = ( | ||||||
| <span> | ||||||
| expand <ArrowDownOutlined /> | ||||||
| </span> | ||||||
| ); | ||||||
|
|
||||||
| const collapseSymbol = ( | ||||||
| <span> | ||||||
| collapse <ArrowUpOutlined /> | ||||||
| </span> | ||||||
| ); | ||||||
|
|
||||||
| const ExpandableText = ({ text, setCurrentHeight }: ExpandableTextProps) => { | ||||||
| const [isExpanded, setIsExpanded] = useState<boolean>(false); | ||||||
| const ref = useRef<HTMLParagraphElement>(null); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| setIsExpanded(false); | ||||||
| }, [text]); | ||||||
|
|
||||||
| useLayoutEffect(() => { | ||||||
| setCurrentHeight( | ||||||
| (ref.current?.clientHeight || DEFAULT_DESCRIPTION_HEIGHT) + | ||||||
| TEXT_BOTTOM_MARGIN | ||||||
| ); | ||||||
| }, [isExpanded, setCurrentHeight]); | ||||||
|
||||||
| }, [isExpanded, setCurrentHeight]); | |
| }, [isExpanded, setCurrentHeight, text]); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export const DEFAULT_DESCRIPTION_HEIGHT = 58; | ||
| export const TEXT_BOTTOM_MARGIN = 14; | ||
| export const SELECT_HEIGHT = 52; | ||
| export const TABS_HEADER_HEIGHT = 62; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { useState, useEffect } from "react"; | ||
| const HEADER_HEIGHT = 48; | ||
| const FOOTER_HEIGHT = 51; | ||
|
|
||
| export function useSiderHeight() { | ||
| const [siderHeight, setSiderHeight] = useState<number>( | ||
| window.innerHeight - HEADER_HEIGHT - FOOTER_HEIGHT | ||
| ); | ||
|
|
||
| useEffect(() => { | ||
| function handleResize() { | ||
| setSiderHeight(window.innerHeight - HEADER_HEIGHT - FOOTER_HEIGHT); | ||
| } | ||
| window.addEventListener("resize", handleResize); | ||
| return () => { | ||
| window.removeEventListener("resize", handleResize); | ||
| }; | ||
| }, []); | ||
|
Comment on lines
+10
to
+18
|
||
|
|
||
| return siderHeight; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed this folder so the component name matched the file name