-
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.
- Loading branch information
Showing
12 changed files
with
670 additions
and
428 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,70 @@ | ||
.table-widget { | ||
display: grid; | ||
|
||
grid-template-columns: 1fr; | ||
grid-template-rows: auto 1fr; | ||
|
||
grid-template-areas: 'toolbar' 'table'; | ||
|
||
gap: 16px; | ||
|
||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.toolbar { | ||
grid-area: toolbar; | ||
border-radius: var(--radius-m); | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.table-container { | ||
grid-area: table; | ||
|
||
border-collapse: collapse; | ||
box-sizing: border-box; | ||
|
||
display: grid; | ||
|
||
position: relative; | ||
|
||
overflow: auto; | ||
} | ||
|
||
.table-header { | ||
grid-row: 1; | ||
grid-column: 1 / -1; | ||
|
||
display: grid; | ||
grid-template-columns: subgrid; | ||
grid-template-rows: subgrid; | ||
|
||
/*position: sticky;*/ | ||
/*top: 0;*/ | ||
} | ||
|
||
.table-body { | ||
grid-column: 1 / -1; | ||
grid-row: 2 / -1; | ||
|
||
display: grid; | ||
|
||
grid-template-columns: subgrid; | ||
grid-template-rows: subgrid; | ||
} | ||
|
||
.table-container > * { | ||
box-sizing: border-box; | ||
} | ||
|
||
.table-header-cell { | ||
display: flex; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
text-overflow: clip; | ||
|
||
font-weight: var(--table-header-weight); | ||
|
||
/*border-top: var(--table-border-width) solid var(--table-border-color);*/ | ||
} |
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,68 @@ | ||
import Spreadsheet from "./viewport.js"; | ||
import { icons } from 'lucide-react'; | ||
|
||
export type Tool = { | ||
description: string; | ||
label: string; | ||
icon: keyof typeof icons | ||
} & (Button | ViewportOptions); | ||
export type Button = { | ||
type: 'button', | ||
onClick: (sheet: Spreadsheet) => void, | ||
}; | ||
export type ViewportOptions = { | ||
type: 'viewport', | ||
} | ||
|
||
export const tools = { | ||
'copy': { | ||
type: 'button', | ||
label: 'Copy', | ||
description: 'Copy Selected Cells', | ||
icon: 'Copy', | ||
onClick: sheet => void 0 | ||
}, | ||
'cut': { | ||
type: 'button', | ||
label: 'Cut', | ||
description: 'Cut Selected Cells', | ||
icon: 'Scissors', | ||
onClick: sheet => void 0 | ||
}, | ||
'paste': { | ||
type: 'button', | ||
label: 'Paste', | ||
description: 'Paste Selected Cells', | ||
icon: 'Clipboard', | ||
onClick: sheet => void 0 | ||
}, | ||
'sort': { | ||
type: 'button', | ||
label: 'Sorting', | ||
description: 'Set Sorting Method', | ||
icon: 'ArrowDownNarrowWide', | ||
onClick: sheet => void 0 | ||
}, | ||
'filter': { | ||
type: 'button', | ||
label: 'Filter', | ||
description: 'Filter viewport', | ||
icon: 'Filter', | ||
onClick: sheet => void 0 | ||
}, | ||
'group': { | ||
type: 'button', | ||
label: 'Group', | ||
description: 'Set grouping options', | ||
icon: 'Group', | ||
onClick: sheet => void 0 | ||
}, | ||
'viewOptions': { | ||
type: 'viewport', | ||
label: "Viewport Options", | ||
description: "Unified viewport options (Sorting, Filter, Grouping, Columns)", | ||
icon: 'View' | ||
} | ||
} satisfies { [ToolName in string]: Tool }; | ||
|
||
export default tools |
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,25 @@ | ||
import React from 'react'; | ||
import * as icons from 'lucide-react'; | ||
|
||
import Spreadsheet from "../viewport.js"; | ||
import {Settings} from "../settings/settingsTab.js"; | ||
import Tools, {Tool} from '../actions.js'; | ||
|
||
export default function Toolbar(props: { settings: Settings, sheet: Spreadsheet }) { | ||
return <div className={"flex toolbar"}> | ||
{props.settings.toolbar | ||
.map(item => typeof item == 'string' ? toolRenderers[Tools[item].type](Tools[item]) : <span className={"gap"}/> )} | ||
</div> | ||
} | ||
|
||
const Icon = (props: { icon: keyof typeof icons.icons, size?: number }) => { | ||
const Icon = icons.icons[props.icon]; | ||
return <Icon size={props.size ?? 12}/> | ||
} | ||
|
||
export const toolRenderers = { | ||
button: tool => <button className={"toolbar-button"}> | ||
<Icon icon={tool.icon} /> | ||
</button>, | ||
viewport: tool => null | ||
} satisfies Record<(typeof Tools[keyof typeof Tools])['type'], (tool: Tool) => React.ReactNode>; |
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.