Updated styles

Updated README
This commit is contained in:
Eugene 2023-07-27 12:22:15 +03:00
parent 8aed4c81b9
commit 6dc20f92e7
6 changed files with 18 additions and 8 deletions

View File

@ -1,9 +1,13 @@
# Modern Spreadsheet # Modern Spreadsheet
## Features:
- High performance spreadsheet based on CanvasAPI. - High performance spreadsheet based on CanvasAPI.
- TypeScript supported - TypeScript supported
- Native scrolling
- Customizable
- Copy & Paste support
## Basic usage ### Basic usage
```ts ```ts
import Spreadsheet from "modern_spreadsheet"; import Spreadsheet from "modern_spreadsheet";
@ -14,7 +18,7 @@ const sheet = new Spreadsheet(target);
//... //...
``` ```
## Save and load data ### Save and load data
```ts ```ts
function saveData() { function saveData() {
@ -30,7 +34,7 @@ function loadData() {
} }
``` ```
## Supported events #### Supported events
- onCellClick - onCellClick
- onSelectionChange - onSelectionChange
- onCellChange - onCellChange
@ -58,7 +62,7 @@ const options: SpreadsheetConstructorProperties = {
const sheet = new Spreadsheet("#spreadsheet", options); const sheet = new Spreadsheet("#spreadsheet", options);
``` ```
## Roadmap ### Roadmap
- ~~Rows number and columns heading render~~ - ~~Rows number and columns heading render~~
- ~~Custom event functions (ex.: onSelectionChange, onCellEdit...). Full list of supported events will available on this page~~ - ~~Custom event functions (ex.: onSelectionChange, onCellEdit...). Full list of supported events will available on this page~~

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@ -83,7 +83,7 @@ export class ColumnsBar {
const isColSelected = this.isColumnSelected(column); const isColSelected = this.isColumnSelected(column);
this.ctx.fillStyle = isColSelected this.ctx.fillStyle = isColSelected
? this.root.styles.cells.selectedBackground ? "#c7ebff"
: "white"; : "white";
this.ctx.strokeStyle = "black"; this.ctx.strokeStyle = "black";
this.ctx.lineWidth = 1; this.ctx.lineWidth = 1;

View File

@ -70,7 +70,7 @@ export class RowsBar {
const isRowSeleted = this.isRowSelected(column); const isRowSeleted = this.isRowSelected(column);
this.ctx.fillStyle = isRowSeleted this.ctx.fillStyle = isRowSeleted
? this.root.styles.cells.selectedBackground ? "#c7ebff"
: "white"; : "white";
this.ctx.strokeStyle = "black"; this.ctx.strokeStyle = "black";
this.ctx.lineWidth = this.resizerHeight; this.ctx.lineWidth = this.resizerHeight;

View File

@ -81,7 +81,10 @@ export class Sheet {
return { x, y, height, width } return { x, y, height, width }
} }
if (!selectedRange && selectedCell) { if (!selectedRange && selectedCell) {
return new RenderBox(this.root.config, selectedCell) const box = new RenderBox(this.root.config, selectedCell)
box.x -= this.root.viewport.left
box.y -= this.root.viewport.top
return box
} }
} }

View File

@ -1,4 +1,4 @@
import Spreadsheet, { SpreadsheetConstructorProperties } from "./main"; import Spreadsheet, { SpreadsheetConstructorProperties, createSampleData } from "./main";
const options: SpreadsheetConstructorProperties = { const options: SpreadsheetConstructorProperties = {
onCellClick: (event, cell) => { onCellClick: (event, cell) => {
@ -17,6 +17,9 @@ const options: SpreadsheetConstructorProperties = {
const sheet = new Spreadsheet("#spreadsheet", options); const sheet = new Spreadsheet("#spreadsheet", options);
const data = createSampleData(600, 800, true)
sheet.loadData(data)
function saveDataToLS() { function saveDataToLS() {
const serializableData = sheet.serializeData(); const serializableData = sheet.serializeData();
localStorage.setItem("sheet", JSON.stringify(serializableData)); localStorage.setItem("sheet", JSON.stringify(serializableData));