-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
219 additions
and
15 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
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
41 changes: 41 additions & 0 deletions
41
packages/erd-editor/src/components/settings/shortcuts/Shortcuts.styles.ts
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,41 @@ | ||
import { css } from '@dineug/r-html'; | ||
|
||
import { fontSize4 } from '@/styles/typography.styles'; | ||
|
||
export const title = css` | ||
${fontSize4}; | ||
`; | ||
|
||
const cell = css` | ||
padding: 12px; | ||
height: 44px; | ||
box-shadow: inset 0 -1px var(--gray-color-5); | ||
`; | ||
|
||
export const table = css` | ||
width: 100%; | ||
text-align: left; | ||
vertical-align: top; | ||
border-collapse: collapse; | ||
border-radius: calc(var(--table-border-radius) - 1px); | ||
border-spacing: 0; | ||
box-sizing: border-box; | ||
height: 0; | ||
th { | ||
font-weight: var(--font-weight-bold); | ||
${cell}; | ||
} | ||
td { | ||
${cell}; | ||
} | ||
`; | ||
|
||
export const shortcutGroup = css` | ||
margin-bottom: 12px; | ||
&:last-child { | ||
margin-bottom: 0; | ||
} | ||
`; |
150 changes: 150 additions & 0 deletions
150
packages/erd-editor/src/components/settings/shortcuts/Shortcuts.ts
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,150 @@ | ||
import { FC, html } from '@dineug/r-html'; | ||
|
||
import { useAppContext } from '@/components/appContext'; | ||
import Kbd from '@/components/primitives/kbd/Kbd'; | ||
import Separator from '@/components/primitives/separator/Separator'; | ||
import { ShortcutOption } from '@/utils/keyboard-shortcut'; | ||
|
||
import * as styles from './Shortcuts.styles'; | ||
|
||
export type ShortcutsProps = {}; | ||
|
||
type ShortcutItem = { | ||
command: string; | ||
shortcuts: ShortcutOption[]; | ||
}; | ||
|
||
const Shortcuts: FC<ShortcutsProps> = (props, ctx) => { | ||
const app = useAppContext(ctx); | ||
|
||
const getItems = (): ShortcutItem[] => { | ||
const { keyBindingMap } = app.value; | ||
|
||
return [ | ||
{ | ||
command: 'Editing', | ||
shortcuts: keyBindingMap.edit, | ||
}, | ||
{ | ||
command: 'Stop', | ||
shortcuts: keyBindingMap.stop, | ||
}, | ||
{ | ||
command: 'Search', | ||
shortcuts: keyBindingMap.find, | ||
}, | ||
{ | ||
command: 'Undo', | ||
shortcuts: keyBindingMap.undo, | ||
}, | ||
{ | ||
command: 'Redo', | ||
shortcuts: keyBindingMap.redo, | ||
}, | ||
{ | ||
command: 'Add Table', | ||
shortcuts: keyBindingMap.addTable, | ||
}, | ||
{ | ||
command: 'Add Column', | ||
shortcuts: keyBindingMap.addColumn, | ||
}, | ||
{ | ||
command: 'Add Memo', | ||
shortcuts: keyBindingMap.addMemo, | ||
}, | ||
{ | ||
command: 'Remove Table, Memo', | ||
shortcuts: keyBindingMap.removeTable, | ||
}, | ||
{ | ||
command: 'Remove Column', | ||
shortcuts: keyBindingMap.removeColumn, | ||
}, | ||
{ | ||
command: 'Primary Key', | ||
shortcuts: keyBindingMap.primaryKey, | ||
}, | ||
{ | ||
command: 'Select All Table, Memo', | ||
shortcuts: keyBindingMap.selectAllTable, | ||
}, | ||
{ | ||
command: 'Select All Column', | ||
shortcuts: keyBindingMap.selectAllColumn, | ||
}, | ||
{ | ||
command: 'Copy Column', | ||
shortcuts: keyBindingMap.copyColumn, | ||
}, | ||
{ | ||
command: 'Paste Column', | ||
shortcuts: keyBindingMap.pasteColumn, | ||
}, | ||
{ | ||
command: 'Relationship Zero One', | ||
shortcuts: keyBindingMap.relationshipZeroOne, | ||
}, | ||
{ | ||
command: 'Relationship Zero N', | ||
shortcuts: keyBindingMap.relationshipZeroN, | ||
}, | ||
{ | ||
command: 'Relationship One Only', | ||
shortcuts: keyBindingMap.relationshipOneOnly, | ||
}, | ||
{ | ||
command: 'Relationship One N', | ||
shortcuts: keyBindingMap.relationshipOneN, | ||
}, | ||
{ | ||
command: 'Table Properties', | ||
shortcuts: keyBindingMap.tableProperties, | ||
}, | ||
{ | ||
command: 'Zoom In', | ||
shortcuts: keyBindingMap.zoomIn, | ||
}, | ||
{ | ||
command: 'Zoom Out', | ||
shortcuts: keyBindingMap.zoomOut, | ||
}, | ||
]; | ||
}; | ||
|
||
return () => { | ||
return html` | ||
<div class=${styles.title}>Shortcuts</div> | ||
<${Separator} space=${12} /> | ||
<table class=${styles.table}> | ||
<thead> | ||
<tr> | ||
<th>Command</th> | ||
<th>Keybinding</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
${getItems().map( | ||
({ command, shortcuts }) => html` | ||
<tr> | ||
<td>${command}</td> | ||
<td> | ||
${shortcuts.map( | ||
({ shortcut }) => | ||
html` | ||
<div class=${styles.shortcutGroup}> | ||
<${Kbd} shortcut=${shortcut} /> | ||
</div> | ||
` | ||
)} | ||
</td> | ||
</tr> | ||
` | ||
)} | ||
</tbody> | ||
</table> | ||
`; | ||
}; | ||
}; | ||
|
||
export default Shortcuts; |
Empty file.
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