Repository navigation
feat(er-diagram): add accessible key and relationship legend (#1401) #1428
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
Merged
NewtTheWolf
merged 3 commits into
TabularisDB:main
from
markankamaransheogarat-sys:feat/er-diagram-legend-1401
Nov 10, 2026
+291
−14
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
3cabb1a
feat(er-diagram): add accessible key and relationship legend (#1401)
markankamaransheogarat-sys be749d0
fix(er-diagram): address code review feedback on popover layout, useE…
markankamaransheogarat-sys dba7010
Merge main and address review feedback
NewtTheWolf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
107 changes: 107 additions & 0 deletions
107
packages/web-ui/src/components/ui/SchemaDiagramLegend.tsx
This file contains hidden or 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,107 @@ | ||
| import {memo, useState, useCallback, useId} from 'react'; | ||
| import {useTranslation} from 'react-i18next'; | ||
| import {Key, Link, Info, ChevronDown, ChevronUp} from 'lucide-react'; | ||
| import clsx from 'clsx'; | ||
| import {useEscapeKey} from '@/hooks/useEscapeKey'; | ||
|
|
||
| export interface SchemaDiagramLegendProps { | ||
| className?: string; | ||
| } | ||
|
|
||
| export const SchemaDiagramLegend = memo(({className}: SchemaDiagramLegendProps) => { | ||
| const {t} = useTranslation(); | ||
| const contentId = useId(); | ||
| const [isOpen, setIsOpen] = useState(false); | ||
| const close = useCallback(() => setIsOpen(false), []); | ||
|
|
||
| // Integrate with the application modal escape stack | ||
| useEscapeKey(isOpen, close); | ||
|
|
||
| return ( | ||
| <div | ||
| className={clsx( | ||
| 'relative bg-elevated/95 backdrop-blur-sm border border-strong rounded-lg shadow-lg overflow-visible text-sm font-sans select-none', | ||
| className, | ||
| )} | ||
| data-testid="schema-diagram-legend" | ||
| > | ||
| <button | ||
| type="button" | ||
| onClick={() => setIsOpen((prev) => !prev)} | ||
| className="flex items-center gap-2 px-3 py-2 text-primary hover:bg-surface-secondary rounded-lg focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus transition-colors font-medium" | ||
| aria-expanded={isOpen} | ||
| aria-controls={contentId} | ||
| title={t('erDiagram.legend', 'Legend')} | ||
| > | ||
| <Info size={16} className="text-secondary" /> | ||
| <span>{t('erDiagram.legend', 'Legend')}</span> | ||
| {isOpen ? ( | ||
| <ChevronUp size={14} className="text-secondary" /> | ||
| ) : ( | ||
| <ChevronDown size={14} className="text-secondary" /> | ||
| )} | ||
| </button> | ||
|
|
||
| {isOpen && ( | ||
| <div | ||
| id={contentId} | ||
| className="absolute top-full left-0 mt-1 p-3 bg-elevated border border-strong rounded-lg shadow-xl flex flex-col gap-2.5 min-w-[260px] max-w-[300px] z-20" | ||
| > | ||
| {/* Primary Key Item */} | ||
| <div className="flex items-start gap-2.5"> | ||
| <div className="mt-0.5 p-1 rounded bg-semantic-pk/10 shrink-0"> | ||
| <Key size={12} className="text-semantic-pk" /> | ||
| </div> | ||
| <div className="flex flex-col min-w-0"> | ||
| <span className="font-semibold text-semantic-pk text-xs leading-tight"> | ||
| {t('erDiagram.primaryKey', 'Primary Key')} | ||
| </span> | ||
| <span className="text-[11px] text-muted leading-tight mt-0.5"> | ||
| {t( | ||
| 'erDiagram.primaryKeyDesc', | ||
| 'Unique column identifying rows in the table', | ||
| )} | ||
| </span> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Foreign Key Item */} | ||
| <div className="flex items-start gap-2.5"> | ||
| <div className="mt-0.5 p-1 rounded bg-semantic-fk/10 shrink-0"> | ||
| <Link size={12} className="text-semantic-fk" /> | ||
| </div> | ||
| <div className="flex flex-col min-w-0"> | ||
| <span className="font-semibold text-semantic-fk text-xs leading-tight"> | ||
| {t('erDiagram.foreignKey', 'Foreign Key')} | ||
| </span> | ||
| <span className="text-[11px] text-muted leading-tight mt-0.5"> | ||
| {t( | ||
| 'erDiagram.foreignKeyDesc', | ||
| 'References a primary or unique key in another table', | ||
| )} | ||
| </span> | ||
| </div> | ||
| </div> | ||
|
|
||
| {/* Relationship Connector */} | ||
| <div className="flex items-start gap-2.5"> | ||
| <div className="mt-0.5 p-1 rounded bg-surface-secondary shrink-0 flex items-center justify-center w-5 h-5"> | ||
| <div className="w-3 h-0.5 bg-accent-primary rounded-full shadow-[0_0_4px_var(--accent-primary)]" /> | ||
| </div> | ||
| <div className="flex flex-col min-w-0"> | ||
| <span className="font-semibold text-primary text-xs leading-tight"> | ||
| {t('erDiagram.relationship', 'Relationship')} | ||
| </span> | ||
| <span className="text-[11px] text-muted leading-tight mt-0.5"> | ||
| {t( | ||
| 'erDiagram.relationshipDesc', | ||
| 'Foreign key reference connecting child and parent tables', | ||
| )} | ||
| </span> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
WARNING: Expanded legend distorts the toolbar layout
The toolbar container (
absolute top-4 left-4 z-10 flex gap-2) uses the defaultitems-stretch. When the legend expands (~150px+ tall), every sibling button (Layout toggle, Export, Show all) stretches to the same height, and the legend also shifts the existing controls to the right. The PR claims it does not interfere with existing toolbar layout. Consideritems-starton the toolbar container, or render the expanded panel as an absolutely-positioned popover anchored under the trigger button.