Skip to content

WIP: DEMO branch with css fixes #298

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

Draft
wants to merge 250 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
250 commits
Select commit Hold shift + click to select a range
5b09c2e
finish up code cleanup and make sure that all styling is close to fig…
SaqAsh Jun 4, 2025
0fa14d9
type theme appropriately instead of settling for any
SaqAsh Jun 4, 2025
62b5ec4
fix styling and add comments for fonts
SaqAsh Jun 4, 2025
376f887
add some permuations of testing and reduce the threshold constants
SaqAsh Jun 4, 2025
afe4e16
final cleanup before pr, remove uneccesary styling
SaqAsh Jun 4, 2025
8e7cc5e
fix logic flaw
SaqAsh Jun 4, 2025
296af83
add minor spacing
SaqAsh Jun 4, 2025
b123752
remove tacky v
SaqAsh Jun 4, 2025
532260f
port over the button implementation from stage into here in order to …
SaqAsh Jun 4, 2025
28a164f
fix minor css styling
SaqAsh Jun 4, 2025
8d86be9
add more configuations to the story
SaqAsh Jun 4, 2025
ed90b72
finish adding all neccasry components for expansion and collapseable …
SaqAsh Jun 4, 2025
cc05e97
fix horizontal scrolling issue with css
SaqAsh Jun 5, 2025
c0b3dc4
initialize the table of contents component
SaqAsh Jun 5, 2025
8d9f78d
handle logic for the actual scrolling into view for scheams
SaqAsh Jun 5, 2025
ee3a2c9
clean up the table of contents, add the relevant functions
SaqAsh Jun 5, 2025
9f2bd1d
cleanup css styling such that it is uniform and has no unessesary att…
SaqAsh Jun 5, 2025
5414669
fix subpar styling for dropdown
SaqAsh Jun 5, 2025
c10619c
code cleanup
SaqAsh Jun 5, 2025
ffa06e0
add an advanced.json to better facilitate visualation of table of con…
SaqAsh Jun 5, 2025
3f5549e
port over the attribute filter from stage
SaqAsh Jun 5, 2025
ce91494
fix naming issue with list
SaqAsh Jun 5, 2025
6c065a5
Merge branch 'feature/Table-of-contents' into feature/attribute-filte…
SaqAsh Jun 5, 2025
6a68b7a
finish up attribute filter dropdown implementation
SaqAsh Jun 5, 2025
eab689f
relocate all interaction panel based things in a different folder for…
SaqAsh Jun 6, 2025
edc0902
moving dropdown into the interaction panel
SaqAsh Jun 6, 2025
2b1c714
initial commit, initializing the component
SaqAsh Jun 6, 2025
41baefa
use theme context instead of individually importing the icon
SaqAsh Jun 6, 2025
24aeabd
complete implementation of the dictionary download button
SaqAsh Jun 6, 2025
7011532
make the download template button actually interactive
SaqAsh Jun 6, 2025
1268d0b
Merge branch 'feature/download-templates' into feature/attribute-filt…
SaqAsh Jun 6, 2025
109773c
reoganize the components all together as one interaction panel story
SaqAsh Jun 6, 2025
0c97a59
finalizing the styling according to the figma
SaqAsh Jun 6, 2025
54d0243
fix styling for buttons
SaqAsh Jun 6, 2025
14fbcb6
Merge branch 'feature/expand-collapse-all-button' into feature/attrib…
SaqAsh Jun 6, 2025
5b7656c
Merge branch 'feature/Table-of-contents' into feature/attribute-filte…
SaqAsh Jun 6, 2025
5598d09
dictionary version implementation finished
SaqAsh Jun 6, 2025
84b5619
initialize the interaction component
SaqAsh Jun 6, 2025
f58ec3f
interaction bar rearrangement and left and right row addition
SaqAsh Jun 9, 2025
449782f
Merge branch 'main' into feature/dictionary-version-switcher
SaqAsh Jun 9, 2025
f4ccb29
make updates to the package.json to make the lectern client available
SaqAsh Jun 9, 2025
97a4f61
implement disasbled state for dropdown
SaqAsh Jun 9, 2025
fc4cee3
add a disasbled state as part of the demo for the dropdown, going to …
SaqAsh Jun 9, 2025
ccaf112
implement disabled state for interaction panel
SaqAsh Jun 9, 2025
ae26b10
interaction panel implement disasbled state in stories
SaqAsh Jun 9, 2025
00cf2fa
add testing for the version switcher
SaqAsh Jun 9, 2025
bc3f058
merge from the version switcher
SaqAsh Jun 9, 2025
5b1768e
Merge branch 'feature/header-component' into feature/interaction-panel
SaqAsh Jun 9, 2025
9280d6a
Added some different cases for the interaction panel
SaqAsh Jun 9, 2025
3d598de
add licencing
SaqAsh Jun 10, 2025
89ed33f
initial component initialization
SaqAsh Jun 10, 2025
30f6bee
allow the ability to actually initalize the openInit
SaqAsh Jun 10, 2025
694931f
add line seperation, fix up styling
SaqAsh Jun 10, 2025
dc2949b
make it so that we have appropriate aligning
SaqAsh Jun 10, 2025
69c2ec6
address preceeding text spacing comment from pr
SaqAsh Jun 10, 2025
174922f
exporting component props
SaqAsh Jun 10, 2025
60dab2d
rename the constant to fit the naming standards better and add commen…
SaqAsh Jun 10, 2025
d372d65
Merge branch 'feature/header-component' into feature/accordian-cards
SaqAsh Jun 10, 2025
6bfcc69
move the state management inside of the accordion, pt1
SaqAsh Jun 10, 2025
322c21d
whitespace
SaqAsh Jun 10, 2025
0d98f89
hover state
SaqAsh Jun 10, 2025
8601b5a
export all props
SaqAsh Jun 10, 2025
36e5af9
defaulted spinner width height and fill values
SaqAsh Jun 10, 2025
d0f4631
change console.log to alerts
SaqAsh Jun 10, 2025
9605e9f
do not control state of other components, addresses pr feedback
SaqAsh Jun 10, 2025
c1f2083
Merge branch 'feature/expand-collapse-all-button' into feature/accord…
SaqAsh Jun 10, 2025
634107b
add back disasbled state from interaction panel
SaqAsh Jun 10, 2025
659a456
generated dictionarypage for now just to see everything working at on…
SaqAsh Jun 10, 2025
50a8e5c
Merge branch 'main' into feature/Table-of-contents
SaqAsh Jun 10, 2025
fe1dd0e
move advanced.json and fix import
SaqAsh Jun 10, 2025
9f29bf9
we want user inputted styles to be in highest priority
SaqAsh Jun 10, 2025
35556bb
export props
SaqAsh Jun 10, 2025
902eccc
change from console.log to alert
SaqAsh Jun 10, 2025
b0b0dab
instead of increasing the border width, add a box shadow instead
SaqAsh Jun 11, 2025
4b42736
make hover state less prominent
SaqAsh Jun 11, 2025
140eaf6
add a new button variant, iconOnly
SaqAsh Jun 11, 2025
229928f
styling buttons such that we have the ability to pass in custom style…
SaqAsh Jun 11, 2025
6bb1355
add the hash
SaqAsh Jun 11, 2025
9b344ed
fix some div hierarchy issues with the spans not properly being stack…
SaqAsh Jun 12, 2025
7de835c
remove errors from stories, need to consider the case for a longer ti…
SaqAsh Jun 12, 2025
7516587
attempt 1 of getting the title to wrap when too big
SaqAsh Jun 12, 2025
1997c6c
implement handling of a long title
SaqAsh Jun 12, 2025
316750b
refactor the read-more/read-less logic
SaqAsh Jun 12, 2025
7744643
make the transition smooth with css without the use of useEffect
SaqAsh Jun 12, 2025
50503e6
clean up css finally
SaqAsh Jun 12, 2025
b2bc3eb
whitespace fix
SaqAsh Jun 12, 2025
2da8a34
general copying pattern
SaqAsh Jun 12, 2025
0c6f710
finalize the url hash navigation
SaqAsh Jun 12, 2025
5973dd4
rework the table of contents dropdown stuff, and chat gpt the diction…
SaqAsh Jun 12, 2025
7db7058
implement pr review changes
SaqAsh Jun 12, 2025
69467f0
add a todo for the buttons rendering
SaqAsh Jun 12, 2025
34445e9
accidentally removed export
SaqAsh Jun 12, 2025
e9a068e
fix naming inside of stories to make it consistent with props
SaqAsh Jun 12, 2025
5f48538
table of contents merge
SaqAsh Jun 13, 2025
03cfa52
collapse button merge
SaqAsh Jun 13, 2025
639334a
move filter dropdown from stage to lectern
SaqAsh Jun 13, 2025
2e3153b
port over attribute filter dropdown from stage
SaqAsh Jun 13, 2025
e9b0eaf
fix states in the interaction panel component
SaqAsh Jun 13, 2025
b82cd39
remove all the extra props that weren't needed
SaqAsh Jun 13, 2025
36419fb
fix the panel with the new props
SaqAsh Jun 16, 2025
e7a0b17
fix errors due to the new dictionary config
SaqAsh Jun 16, 2025
9bd6322
add disasbled state
SaqAsh Jun 16, 2025
d337d8e
fix filter label
SaqAsh Jun 16, 2025
1cfdc68
Merge branch 'main' into feature/interaction-panel
SaqAsh Jun 16, 2025
344da2b
file download pattern following
SaqAsh Jun 16, 2025
9133031
make the stories more case handling
SaqAsh Jun 16, 2025
1de4f70
make the icon filedownload follow the common pattern
SaqAsh Jun 16, 2025
a7e293f
fix the icons
SaqAsh Jun 16, 2025
d8478ad
download templates pr review comments
SaqAsh Jun 16, 2025
2e8400a
Merge branch 'main' into feature/Table-of-contents
SaqAsh Jun 16, 2025
96ff5e5
Merge branch 'main' into feature/expand-collapse-all-button
SaqAsh Jun 16, 2025
0f1f851
Merge branch 'main' into feature/header-component
SaqAsh Jun 16, 2025
a7edf37
Merge branch 'feature/interaction-panel' into feature/accordian-cards
SaqAsh Jun 16, 2025
06fe036
data dictionary page was a mess and not needed currently
SaqAsh Jun 16, 2025
4c474e3
the individual schema does not need the description or name
SaqAsh Jun 17, 2025
e58ee03
Remove max width from the table and make sure that the table is refac…
SaqAsh Jun 17, 2025
0115324
fix up the table columns, schemaField Html is useless now
SaqAsh Jun 17, 2025
42a6d1e
add back the field's description name after accidental removal
SaqAsh Jun 17, 2025
8bc0b79
fix css
SaqAsh Jun 17, 2025
8b13278
fix the rendering of the descriptions
SaqAsh Jun 17, 2025
480a313
render examples fields if available inside of the meta
SaqAsh Jun 17, 2025
e4d542f
render examples
SaqAsh Jun 17, 2025
5e528f8
clean up the handling for the hash
SaqAsh Jun 17, 2025
3f61b33
add the filter dropdown from stage
SaqAsh Jun 18, 2025
a02c93b
finishing up code clean-up
SaqAsh Jun 18, 2025
600f63f
clean up code to meet standards better
SaqAsh Jun 18, 2025
a6c9d47
clean up the stories and spread through the mockedproperties
SaqAsh Jun 18, 2025
9d6a0cb
some slob generated to get some scroll behaviour working
SaqAsh Jun 19, 2025
ab90868
fix the fileType
SaqAsh Jun 19, 2025
353e806
fixed code readibility, abstracted things into functions
SaqAsh Jun 19, 2025
94d3338
remove over engineering
SaqAsh Jun 19, 2025
9879efb
abstract download button out of the component, shouldn't be needing t…
SaqAsh Jun 19, 2025
bd627d7
Merge branch 'feature/interaction-panel' into feature/accordian-cards
SaqAsh Jun 19, 2025
4565336
fix error
SaqAsh Jun 19, 2025
1bf7e66
make sure that there is no sharing of the types.
SaqAsh Jun 19, 2025
6a5a487
fix cross referencing issues
SaqAsh Jun 19, 2025
e1de3f8
Merge branch 'feature/interaction-panel' into feature/accordian-cards
SaqAsh Jun 19, 2025
f9568ce
Merge branch 'feature/header-component' into feature/interaction-panel
SaqAsh Jun 19, 2025
92b43c9
useable state for the table scrolling
SaqAsh Jun 19, 2025
5ccf451
commit
SaqAsh Jun 20, 2025
d564435
testing
SaqAsh Jun 20, 2025
4a66afb
Merge remote-tracking branch 'origin/feature/schema-table-a' into fea…
SaqAsh Jun 20, 2025
6a23c4f
FIX VITE CONFIG ISSUES
SaqAsh Jun 20, 2025
8876368
slight refactor
SaqAsh Jun 20, 2025
24cc1a4
Allowed Values working... kinda
SaqAsh Jun 21, 2025
8059255
got a googled pill component, and pasted it in
SaqAsh Jun 22, 2025
7ace926
pill implementation complete
SaqAsh Jun 22, 2025
830cf33
capitalize the first letter since that is required in the figma
SaqAsh Jun 22, 2025
e032f3b
conditional restrictions schema table part c done
SaqAsh Jun 22, 2025
9792fa5
delimted requirement finish
SaqAsh Jun 22, 2025
af66e7e
add sticky header
SaqAsh Jun 22, 2025
93cbadb
slight refactor
SaqAsh Jun 23, 2025
69e6907
schema a b and the other tickets almost done
SaqAsh Jun 23, 2025
f221ab7
implement the modal button
SaqAsh Jun 23, 2025
97b3b5e
some fonting changes
SaqAsh Jun 23, 2025
d0394c0
handle primary key
SaqAsh Jun 23, 2025
3e0eeda
appropriately type examples
SaqAsh Jun 23, 2025
8b69c4f
add borders
SaqAsh Jun 24, 2025
8ae8b69
remove set timeout used for debugging purposes
SaqAsh Jun 24, 2025
92fce9e
remove classname
SaqAsh Jun 24, 2025
b7f3225
address pr feedback
SaqAsh Jun 24, 2025
acce16f
address pr feedback
SaqAsh Jun 24, 2025
dc36553
append quotes onto the words
SaqAsh Jun 24, 2025
7c40856
some css changes
SaqAsh Jun 24, 2025
c54ec9a
more bolding
SaqAsh Jun 24, 2025
c12142b
fix some logical issues as well as some css
SaqAsh Jun 24, 2025
bae83b1
css changes for the table
SaqAsh Jun 24, 2025
85216b2
code style fixes
SaqAsh Jun 24, 2025
19e4079
Merge branch 'feature/Table-of-contents' into feature/interaction-panel
SaqAsh Jun 24, 2025
0feb97b
Merge branch 'feature/expand-collapse-all-button' into feature/intera…
SaqAsh Jun 24, 2025
cd9ede9
Merge branch 'feature/header-component' into feature/interaction-panel
SaqAsh Jun 24, 2025
b39af9b
remove the side effects inside of the TableOfContentsDropdown
SaqAsh Jun 24, 2025
e9fd874
Merge branch 'main' into feature/interaction-panel
SaqAsh Jun 25, 2025
f76e907
naming consistency fixes and fix any css
SaqAsh Jun 25, 2025
d0db70d
revert some cleanup since its messed up some stuff
SaqAsh Jun 25, 2025
63d5c30
Merge branch 'feature/interaction-panel' into feature/accordian-cards
SaqAsh Jun 25, 2025
a2f69bb
remove the bug accidentally introduced
SaqAsh Jun 25, 2025
9cb7474
Merge branch 'feature/accordion-cards' into feature/schema-table
SaqAsh Jun 25, 2025
9430030
seperate the return type into prefix and content to easily render
SaqAsh Jun 25, 2025
c06e62b
add the bolding for the prefixes
SaqAsh Jun 26, 2025
36bd606
fix the required when styling
SaqAsh Jun 26, 2025
91ac153
remove hello world className
SaqAsh Jun 26, 2025
487be50
add new lines
SaqAsh Jun 26, 2025
1dff495
some naming changes and getting rid of pill dark mode
SaqAsh Jun 26, 2025
9606a27
fix the allowed values
SaqAsh Jun 27, 2025
67f084b
Merge branch 'main' into feature/accordion-cards
SaqAsh Jul 2, 2025
85c3a76
remove comments and add licencing and export type
SaqAsh Jul 2, 2025
14304b3
remove useless comments
SaqAsh Jul 2, 2025
cacce41
cleanup types and html semantics
SaqAsh Jul 2, 2025
f4c5813
some functional changes
SaqAsh Jul 2, 2025
d1ac0c1
further code cleanup
SaqAsh Jul 2, 2025
c5d99d2
accidental file change fix
SaqAsh Jul 2, 2025
8ee7415
accidental file change fix
SaqAsh Jul 2, 2025
667f366
format import for pr
SaqAsh Jul 2, 2025
f735547
Merge branch 'feature/accordion-cards' into feature/schema-table
SaqAsh Jul 2, 2025
14e5770
undo to reduce number of files reviewed
SaqAsh Jul 2, 2025
7e6a70d
reduce diff with removing uneccessary code changes
SaqAsh Jul 2, 2025
92fd010
add line breaks and fix up formatting if needed
SaqAsh Jul 2, 2025
e3c3eee
clean up the header component with the use of the readmore
SaqAsh Jul 2, 2025
0729747
generated demo page.
SaqAsh Jul 2, 2025
59cdf22
table width fix
SaqAsh Jul 2, 2025
23d7820
cleanup imports
SaqAsh Jul 2, 2025
d2ed3f1
fix overlaying css issue
SaqAsh Jul 3, 2025
faa4ba5
fix vertical alignment
SaqAsh Jul 3, 2025
e111d4c
add mock data
SaqAsh Jul 3, 2025
2cd1202
add version switching
SaqAsh Jul 3, 2025
ee63fc3
Update packages/ui/src/common/ReadMoreText.tsx
SaqAsh Jul 3, 2025
eb12646
fix typo as well as fix the import spacing
SaqAsh Jul 3, 2025
2ef89ff
move copying logic into a seperate hook
SaqAsh Jul 3, 2025
f4280ba
make whole area clickable
SaqAsh Jul 3, 2025
a42aeae
fix html type
SaqAsh Jul 3, 2025
c939f27
suggestion for the download dictionary buttont to be cleanedup interally
SaqAsh Jul 3, 2025
79ae687
remove children dependency, content isn't dynamic once the page is lo…
SaqAsh Jul 3, 2025
3484c90
Merge branch 'feature/accordion-cards' into feature/demo
SaqAsh Jul 3, 2025
5f78729
comments
SaqAsh Jul 4, 2025
97d7790
reduce the use of prop via exporting the hook
SaqAsh Jul 4, 2025
a28df45
use ref instead of getElementById
SaqAsh Jul 4, 2025
a1f0027
slight refactor with the props
SaqAsh Jul 4, 2025
553daec
add comment for why we have mock props
SaqAsh Jul 4, 2025
6fb2b31
fix the semantic html issues
SaqAsh Jul 4, 2025
3e5dfee
finish fixing up css
SaqAsh Jul 4, 2025
13f32d7
fix any other redundant css and move comment
SaqAsh Jul 4, 2025
a75f9be
Merge branch 'feature/accordion-cards' into feature/demo
SaqAsh Jul 4, 2025
e6af220
fix dropdown css
SaqAsh Jul 4, 2025
5dc9b75
make the header sticky
SaqAsh Jul 4, 2025
c9f20b5
remove uneccessary styling and like z-index
SaqAsh Jul 4, 2025
83a503d
fix filtering logic
SaqAsh Jul 4, 2025
ba7057e
fix up a lot of the logic and make it such that we actually have pro…
SaqAsh Jul 4, 2025
c1879bb
remove all redundant css
SaqAsh Jul 4, 2025
22f4994
fix html semantic issues
SaqAsh Jul 4, 2025
d20b93e
fix some accessibility
SaqAsh Jul 7, 2025
724d6bd
nuked old typography inside of theme and nuked styles folder that was…
SaqAsh Jul 7, 2025
5c03dd8
refactored pill component with the new fonting
SaqAsh Jul 7, 2025
71a9af3
finish refactoring the dictionary header with appropriate fonts
SaqAsh Jul 7, 2025
1f4aae6
fix the linter issue with the allowed values columns
SaqAsh Jul 7, 2025
14281db
fix the read more text with the errors in fonting
SaqAsh Jul 7, 2025
823df17
fix the table header and fields fonting
SaqAsh Jul 7, 2025
56fa752
fix the typing slightly
SaqAsh Jul 7, 2025
9da52f7
fix the accordion hash navigation scrolling bug, and fix typography i…
SaqAsh Jul 7, 2025
a59ac2e
undo typing fix, broke the value
SaqAsh Jul 7, 2025
0a547ea
fix the hash navigation scrolling issue, however the hash navigation …
SaqAsh Jul 7, 2025
f56da24
fix the icons
SaqAsh Jul 7, 2025
620bc24
fix the scroll into view
SaqAsh Jul 7, 2025
8823df1
full width to pill
SaqAsh Jul 7, 2025
50b0407
Merge branch 'main' into feature/demo
SaqAsh Jul 14, 2025
497a399
merge fixes, branch now building
SaqAsh Jul 14, 2025
858b3be
port over the pill from main
SaqAsh Jul 14, 2025
9ff7aaa
remove allowed values column
SaqAsh Jul 14, 2025
015f2cc
reduce diff...
SaqAsh Jul 14, 2025
a94efd2
accessiblity fixes
SaqAsh Jul 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/ui/src/common/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@
/** @jsxImportSource @emotion/react */

import { css } from '@emotion/react';
import { ReactNode, useMemo, useState } from 'react';
import { ReactNode, useEffect, useMemo, useState } from 'react';

import AccordionItem from './AccordionItem';

export type AccordionData = {
title: string;
openOnInit: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

description?: string;
content: ReactNode;
schemaName: string;
};
export type AccordionProps = {
accordionItems: Array<AccordionData>;
collapseAll: boolean;
};

export type AccordionOpenState = {
Expand Down Expand Up @@ -93,10 +93,16 @@ const accordionStyle = css`
display: flex;
flex-direction: column;
gap: 24px;
cursor: pointer;
`;

const Accordion = ({ accordionItems }: AccordionProps) => {
const [openStates, setOpenStates] = useState<boolean[]>(accordionItems.map((item) => item.openOnInit));
const Accordion = ({ accordionItems, collapseAll }: AccordionProps) => {
const [openStates, setOpenStates] = useState<boolean[]>(accordionItems.map(() => collapseAll));

useEffect(() => {
setOpenStates(accordionItems.map(() => collapseAll));
}, [collapseAll]);

const handleToggle = (index: number) => {
setOpenStates((prev) => prev.map((isOpen, i) => (i === index ? !isOpen : isOpen)));
};
Expand Down
68 changes: 32 additions & 36 deletions packages/ui/src/common/Accordion/AccordionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ const accordionItemStyle = (theme: Theme) => css`
overflow: hidden;
background-color: #ffffff;
box-shadow:
0 2px 6px rgba(70, 63, 63, 0.05),
0 2px 6px rgba(70, 63, 63, 0.3),
0 0 0 0.3px ${theme.colors.black};
&:hover {
box-shadow:
0 2px 6px rgba(70, 63, 63, 0.15),
0 2px 6px rgba(70, 63, 63, 0.5),
0 0 0 0.3px ${theme.colors.black};
}
transition: all 0.3s ease;
Expand All @@ -71,34 +71,35 @@ const accordionItemButtonStyle = (theme: Theme) => css`
display: flex;
border: none;
align-items: center;
color: ${theme.colors.accent_dark};
cursor: pointer;
${theme.typography?.button};
text-align: left;
background: transparent;
padding: 8px 0;
flex: 1;
padding: 8px 0px;
`;
const titleStyle = (theme: Theme) => css`
${theme.typography?.subtitleSecondary};
color: ${theme.colors.accent_dark};
text-align: left;
`;

const chevronStyle = (isOpen: boolean) => css`
transform: ${isOpen ? 'rotate(0deg)' : 'rotate(-90deg)'};
transition: transform 0.2s ease;
margin-right: 12px;
flex-shrink: 0;
`;

const contentContainerStyle = css`
display: flex;
flex-direction: column;
align-items: flex-start;
flex: 1;
`;

const titleRowStyle = css`
display: flex;
gap: 2px;
align-items: center;
width: 100%;
margin-bottom: 10px;
flex-direction: auto;
flex-wrap: wrap;
`;

const hashIconStyle = (theme: Theme) => css`
Expand All @@ -107,27 +108,19 @@ const hashIconStyle = (theme: Theme) => css`
background: transparent;
border: none;
cursor: pointer;
padding: 0;

svg {
border-bottom: 2px solid ${theme.colors.secondary};
}

&:hover {
opacity: 1;
}
`;

const descriptionWrapperStyle = (theme: Theme) => css`
${theme.typography?.label2};
color: ${theme.colors.grey_5};
${theme.typography.paragraphSmall};
color: ${theme.colors.black};
overflow-wrap: break-word;
width: 100%;
`;

const downloadButtonContainerStyle = css`
flex-shrink: 0;
margin-right: 8px;
margin-left: 16px;
`;

const accordionCollapseStyle = (isOpen: boolean) => css`
Expand All @@ -137,7 +130,7 @@ const accordionCollapseStyle = (isOpen: boolean) => css`
`;

const accordionItemContentStyle = css`
padding: 30px;
padding: 0px 30px 30px 30px;
`;

const contentInnerContainerStyle = (theme: Theme) => css`
Expand All @@ -148,16 +141,15 @@ const contentInnerContainerStyle = (theme: Theme) => css`

const handleInitialHashCheck = (
windowLocationHash: string,
accordionData: AccordionData,
openState: AccordionOpenState,
indexString: string,
accordionRef: RefObject<HTMLLIElement | null>,
) => {
if (window.location.hash === windowLocationHash) {
if (!accordionData.openOnInit) {
openState.toggle();
}
accordionRef.current?.id === indexString ? accordionRef.current.scrollIntoView({ behavior: 'smooth' }) : null;
openState.toggle();
accordionRef.current?.id === indexString ?
accordionRef.current.scrollIntoView({ block: 'center', behavior: 'smooth' })
: null;
}
};

Expand All @@ -167,8 +159,10 @@ const hashOnClick = (
setClipboardContents: (currentSchema: string) => void,
) => {
event.stopPropagation();
window.location.hash = windowLocationHash;
setClipboardContents(window.location.href);
event.preventDefault();
setClipboardContents(
`${window.location.origin}${window.location.pathname}${window.location.search}${windowLocationHash}`,
);
};

const AccordionItem = ({ index, accordionData, openState }: AccordionItemProps) => {
Expand All @@ -182,36 +176,38 @@ const AccordionItem = ({ index, accordionData, openState }: AccordionItemProps)
const windowLocationHash = `#${index}`;

useEffect(() => {
handleInitialHashCheck(windowLocationHash, accordionData, openState, indexString, accordionRef);
setTimeout(() => {
handleInitialHashCheck(windowLocationHash, openState, indexString, accordionRef);
}, 100);
Comment on lines +179 to +181
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set timeout is needed since there is some timing issue with rendering the accordion and scrolling into view and making sure it opens

}, []);

return (
<li ref={accordionRef} role="button" css={accordionItemStyle(theme)} id={indexString} onClick={openState.toggle}>
<div css={accordionItemTitleStyle}>
<div css={contentContainerStyle}>
<div css={titleRowStyle}>
<button type="button" css={accordionItemButtonStyle(theme)}>
<button css={accordionItemButtonStyle(theme)}>
<ChevronDown
fill={theme.colors.accent_dark}
width={16}
height={16}
style={chevronStyle(openState.isOpen)}
/>
<span>{title}</span>
</button>
<span css={titleStyle(theme)}>{title}</span>
<button
type="button"
css={hashIconStyle(theme)}
onClick={(event) => hashOnClick(event, windowLocationHash, setClipboardContents)}
>
<Hash width={20} height={20} fill={theme.colors.secondary} />
</button>
<ReadMoreText maxLines={MAX_LINES_BEFORE_EXPAND} wrapperStyle={descriptionWrapperStyle}>
{description}
</ReadMoreText>
</div>
<ReadMoreText maxLines={MAX_LINES_BEFORE_EXPAND} wrapperStyle={descriptionWrapperStyle}>
{description}
</ReadMoreText>
</div>
<div css={downloadButtonContainerStyle}>
<div>
{/* Mock props for the dictionary since we haven't implemented the download per schema yet */}
<DictionaryDownloadButton
lecternUrl=""
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/common/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const getContentStyles = (theme: Theme, shouldShowLoading: boolean) => css`
display: flex;
align-items: center;
gap: 8px;
${theme.typography.button};
${theme.typography.subtitleSecondary};
color: inherit;
white-space: nowrap;
overflow: hidden;
Expand Down
35 changes: 23 additions & 12 deletions packages/ui/src/common/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ const chevronStyle = (open: boolean) => css`
`;

const dropDownTitleStyle = (theme: Theme) => css`
${theme.typography?.button};
${theme.typography?.subtitleSecondary};
color: ${theme.colors.accent_dark};
`;

const dropdownMenuStyle = (theme: Theme) => css`
${theme.typography?.button};
all: unset;
${theme.typography?.subtitleSecondary};
position: absolute;
top: calc(100% + 5px);
width: 100%;
Expand All @@ -82,6 +83,9 @@ const dropdownMenuStyle = (theme: Theme) => css`
padding-top: 5px;
border-radius: 9px;
padding-bottom: 5px;
z-index: 100;
max-height: 150px;
overflow-y: auto;
`;

type MenuItem = {
Expand Down Expand Up @@ -128,23 +132,30 @@ const Dropdown = ({ menuItems = [], title, leftIcon, disabled = false }: DropDow

const renderMenuItems = () => {
return menuItems.map(({ label, action }) => (
<DropDownItem key={label} action={action}>
<DropDownItem key={label} action={action} onItemClick={() => setOpen(false)}>
{label}
</DropDownItem>
));
};

return (
<div ref={dropdownRef} css={parentStyle}>
<div>
<div css={dropdownButtonStyle({ theme, disabled })} onClick={handleToggle}>
{leftIcon}
<span css={dropDownTitleStyle(theme)}>{title}</span>
<ChevronDown fill={theme.colors?.accent_dark} width={18} height={18} style={chevronStyle(open)} />
</div>

{open && !disabled && <div css={dropdownMenuStyle(theme)}>{renderMenuItems()}</div>}
</div>
<button
css={dropdownButtonStyle({ theme, disabled })}
onClick={handleToggle}
aria-haspopup="menu"
aria-expanded={open}
disabled={disabled}
>
{leftIcon}
<span css={dropDownTitleStyle(theme)}>{title}</span>
<ChevronDown fill={theme.colors?.accent_dark} width={18} height={18} style={chevronStyle(open)} />
</button>
{open && !disabled && (
<menu role="menu" css={dropdownMenuStyle(theme)}>
{renderMenuItems()}
</menu>
)}
</div>
);
};
Expand Down
30 changes: 22 additions & 8 deletions packages/ui/src/common/Dropdown/DropdownItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
/** @jsxImportSource @emotion/react */

import { css, SerializedStyles } from '@emotion/react';
import { ReactNode } from 'react';
import React, { ReactNode } from 'react';

import type { Theme } from '../../theme';
import { useThemeContext } from '../../theme/ThemeContext';

type DropDownItemProps = {
action?: string | (() => void);
children: ReactNode;
onItemClick?: () => void;
customStyles?: {
hover?: SerializedStyles;
base?: SerializedStyles;
Expand All @@ -38,8 +40,7 @@ type DropDownItemProps = {
const styledListItemStyle = (theme: Theme, customStyles?: any) => css`
display: flex;
min-height: 100%;
padding-bottom: 5px;
height: 100%;
padding: 10px;
align-items: center;
border-radius: 9px;
justify-content: center;
Expand All @@ -52,18 +53,31 @@ const styledListItemStyle = (theme: Theme, customStyles?: any) => css`
${customStyles?.base}
`;

const DropDownItem = ({ children, action, customStyles }: DropDownItemProps) => {
const DropDownItem = ({ children, action, onItemClick, customStyles }: DropDownItemProps) => {
const theme = useThemeContext();
const content = <div css={styledListItemStyle(theme, customStyles)}>{children}</div>;

const handleClick = () => {
if (typeof action === 'function') {
action();
}
if (onItemClick) {
onItemClick();
}
};

if (typeof action === 'function') {
return (
<div onClick={action} css={styledListItemStyle(theme, customStyles)}>
<li role="menuitem" onClick={handleClick} css={styledListItemStyle(theme, customStyles)}>
{children}
</div>
</li>
);
}

return content;
return (
<li role="menuitem" css={styledListItemStyle(theme, customStyles)}>
{children}
</li>
);
};

export default DropDownItem;
8 changes: 4 additions & 4 deletions packages/ui/src/common/ReadMoreText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ export type ReadMoreTextProps = {
};

const defaultWrapperStyle = (theme: Theme) => css`
${theme.typography?.label2};
color: ${theme.colors.grey_5};
${theme.typography.paragraphSmall};
color: ${theme.colors.black};
padding: 4px 8px;
word-wrap: break-word;
overflow-wrap: break-word;
`;

const linkStyle = (theme: Theme) => css`
${theme.typography?.label2};
color: ${theme.colors.accent_dark};
${theme.typography.captionBold};
color: ${theme.colors.black};
cursor: pointer;
display: inline-flex;
align-items: center;
Expand Down
Loading