Add icons for all data types

This commit is contained in:
Andrew Kingston 2023-03-14 08:52:32 +00:00
parent f2cf174557
commit aefdfabe39
3 changed files with 16 additions and 11 deletions

View File

@ -1,8 +1,6 @@
<script>
import { getContext } from "svelte"
import SheetCell from "./cells/SheetCell.svelte"
import DataCell from "./cells/DataCell.svelte"
import { getCellRenderer } from "./renderers"
export let row
export let idx
@ -11,12 +9,10 @@
selectedCellId,
reorder,
selectedRows,
rows,
renderedColumns,
hoveredRowId,
selectedCellMap,
selectedCellRow,
menu,
} = getContext("sheet")
$: rowSelected = !!$selectedRows[row._id]

View File

@ -18,7 +18,6 @@
config,
selectedCellMap,
selectedCellRow,
menu,
} = getContext("sheet")
$: scrollLeft = $scroll.left

View File

@ -5,12 +5,22 @@ export const getColor = (idx, opacity = 0.3) => {
return `hsla(${((idx + 1) * 222) % 360}, 90%, 75%, ${opacity})`
}
const DataTypeIconMap = {
options: "Dropdown",
datetime: "Date",
text: "Text",
barcodeqr: "Camera",
longform: "TextAlignLeft",
array: "Dropdown",
number: "Text",
boolean: "Boolean",
attachment: "AppleFiles",
link: "Link",
formula: "Calculator",
json: "Brackets",
}
export const getIconForField = field => {
const type = field.schema.type
if (type === "options") {
return "Dropdown"
} else if (type === "datetime") {
return "Date"
}
return "Text"
return DataTypeIconMap[type] || "Text"
}