Skip to content

Commit

Permalink
Linter
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Sep 6, 2023
1 parent 97f9c94 commit afb882f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 32 deletions.
60 changes: 40 additions & 20 deletions examples/example-datagrid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 18.0,
Name: 'chevrolet chevelle malibu',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/1966_Chevrolet_Chevelle_SS_%2832985111206%29.jpg/420px-1966_Chevrolet_Chevelle_SS_%2832985111206%29.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/1966_Chevrolet_Chevelle_SS_%2832985111206%29.jpg/420px-1966_Chevrolet_Chevelle_SS_%2832985111206%29.jpg',
index: 0,
Acceleration: 12.0,
Year: '1970-01-01',
Expand All @@ -986,7 +987,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 15.0,
Name: 'buick skylark 320',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/1972_Buick_Skylark_Front.jpg/420px-1972_Buick_Skylark_Front.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1d/1972_Buick_Skylark_Front.jpg/420px-1972_Buick_Skylark_Front.jpg',
index: 1,
Acceleration: 11.5,
Year: '1970-01-01',
Expand All @@ -999,7 +1001,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 18.0,
Name: 'plymouth satellite',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/66Sat.jpg/420px-66Sat.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/66Sat.jpg/420px-66Sat.jpg',
index: 2,
Acceleration: 11.0,
Year: '1970-01-01',
Expand All @@ -1012,7 +1015,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 16.0,
Name: 'amc rebel sst',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/1968_AMC_Rebel_Station_Wagon-GoldWhite.jpg/420px-1968_AMC_Rebel_Station_Wagon-GoldWhite.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/1968_AMC_Rebel_Station_Wagon-GoldWhite.jpg/420px-1968_AMC_Rebel_Station_Wagon-GoldWhite.jpg',
index: 3,
Acceleration: 12.0,
Year: '1970-01-01',
Expand All @@ -1025,7 +1029,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 17.0,
Name: 'ford torino',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/1970_ford_torino_cobra_sportsroof_chiolero.jpg/420px-1970_ford_torino_cobra_sportsroof_chiolero.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/1970_ford_torino_cobra_sportsroof_chiolero.jpg/420px-1970_ford_torino_cobra_sportsroof_chiolero.jpg',
index: 4,
Acceleration: 10.5,
Year: '1970-01-01',
Expand All @@ -1038,7 +1043,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 15.0,
Name: 'ford galaxie 500',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/92/1963_Ford_Galaxie_sedan_2_--_06-05-2010.jpg/420px-1963_Ford_Galaxie_sedan_2_--_06-05-2010.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/9/92/1963_Ford_Galaxie_sedan_2_--_06-05-2010.jpg/420px-1963_Ford_Galaxie_sedan_2_--_06-05-2010.jpg',
index: 5,
Acceleration: 10.0,
Year: '1970-01-01',
Expand All @@ -1051,7 +1057,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 14.0,
Name: 'chevrolet impala',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/28/1965_Chevrolet_Impala_300_hp_V8_big_Block_Engine.JPG/420px-1965_Chevrolet_Impala_300_hp_V8_big_Block_Engine.JPG',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/2/28/1965_Chevrolet_Impala_300_hp_V8_big_Block_Engine.JPG/420px-1965_Chevrolet_Impala_300_hp_V8_big_Block_Engine.JPG',
index: 6,
Acceleration: 9.0,
Year: '1970-01-01',
Expand All @@ -1064,7 +1071,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 14.0,
Name: 'plymouth fury iii',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/0e/1959_Plymouth_Sport_Fury_photo-13.JPG/420px-1959_Plymouth_Sport_Fury_photo-13.JPG',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/0/0e/1959_Plymouth_Sport_Fury_photo-13.JPG/420px-1959_Plymouth_Sport_Fury_photo-13.JPG',
index: 7,
Acceleration: 8.5,
Year: '1970-01-01',
Expand All @@ -1077,7 +1085,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 14.0,
Name: 'pontiac catalina',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Pontiac_Catalina_front.jpg/420px-Pontiac_Catalina_front.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Pontiac_Catalina_front.jpg/420px-Pontiac_Catalina_front.jpg',
index: 8,
Acceleration: 10.0,
Year: '1970-01-01',
Expand All @@ -1090,7 +1099,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 15.0,
Name: 'amc ambassador dpl',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/1964_Rambler_Ambassador_990_H_in_black_and_white_with_red_interior_at_2017_AMO_meet_01of16.jpg/420px-1964_Rambler_Ambassador_990_H_in_black_and_white_with_red_interior_at_2017_AMO_meet_01of16.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/4/4c/1964_Rambler_Ambassador_990_H_in_black_and_white_with_red_interior_at_2017_AMO_meet_01of16.jpg/420px-1964_Rambler_Ambassador_990_H_in_black_and_white_with_red_interior_at_2017_AMO_meet_01of16.jpg',
index: 9,
Acceleration: 8.5,
Year: '1970-01-01',
Expand All @@ -1103,7 +1113,8 @@ namespace Data {
Origin: 'Europe',
Miles_per_Gallon: null,
Name: 'citroen ds-21 pallas',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/Festival_automobile_international_2018_-_Citro%C3%ABn_DS_21_-_1965_-_002.jpg/300px-Festival_automobile_international_2018_-_Citro%C3%ABn_DS_21_-_1965_-_002.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/Festival_automobile_international_2018_-_Citro%C3%ABn_DS_21_-_1965_-_002.jpg/300px-Festival_automobile_international_2018_-_Citro%C3%ABn_DS_21_-_1965_-_002.jpg',
index: 10,
Acceleration: 17.5,
Year: '1970-01-01',
Expand All @@ -1116,7 +1127,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: null,
Name: 'chevrolet chevelle concours (sw)',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/8f/1969_Chevrolet_Chevelle_SS396_2_door_Hardtop_%2825260012813%29.jpg/270px-1969_Chevrolet_Chevelle_SS396_2_door_Hardtop_%2825260012813%29.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/8/8f/1969_Chevrolet_Chevelle_SS396_2_door_Hardtop_%2825260012813%29.jpg/270px-1969_Chevrolet_Chevelle_SS396_2_door_Hardtop_%2825260012813%29.jpg',
index: 11,
Acceleration: 11.5,
Year: '1970-01-01',
Expand All @@ -1129,7 +1141,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: null,
Name: 'ford torino (sw)',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/1970_ford_torino_cobra_sportsroof_chiolero.jpg/420px-1970_ford_torino_cobra_sportsroof_chiolero.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/0/03/1970_ford_torino_cobra_sportsroof_chiolero.jpg/420px-1970_ford_torino_cobra_sportsroof_chiolero.jpg',
index: 12,
Acceleration: 11.0,
Year: '1970-01-01',
Expand All @@ -1142,7 +1155,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: null,
Name: 'plymouth satellite (sw)',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/66Sat.jpg/420px-66Sat.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/66Sat.jpg/420px-66Sat.jpg',
index: 13,
Acceleration: 10.5,
Year: '1970-01-01',
Expand All @@ -1155,7 +1169,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: null,
Name: 'amc rebel sst (sw)',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/1968_AMC_Rebel_Station_Wagon-GoldWhite.jpg/420px-1968_AMC_Rebel_Station_Wagon-GoldWhite.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/7/71/1968_AMC_Rebel_Station_Wagon-GoldWhite.jpg/420px-1968_AMC_Rebel_Station_Wagon-GoldWhite.jpg',
index: 14,
Acceleration: 11.0,
Year: '1970-01-01',
Expand All @@ -1168,7 +1183,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 15.0,
Name: 'dodge challenger se',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/1970_Dodge_Challenger_RT_440_Magnum_%2813440447413%29.jpg/420px-1970_Dodge_Challenger_RT_440_Magnum_%2813440447413%29.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/e/eb/1970_Dodge_Challenger_RT_440_Magnum_%2813440447413%29.jpg/420px-1970_Dodge_Challenger_RT_440_Magnum_%2813440447413%29.jpg',
index: 15,
Acceleration: 10.0,
Year: '1970-01-01',
Expand All @@ -1181,7 +1197,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 14.0,
Name: "plymouth 'cuda 340",
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/4/49/%2770_Plymouth_Barracuda_%28%2711_Auto_classique_VAQ_Mont_St-Hilaire%29.JPG/420px-%2770_Plymouth_Barracuda_%28%2711_Auto_classique_VAQ_Mont_St-Hilaire%29.JPG',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/4/49/%2770_Plymouth_Barracuda_%28%2711_Auto_classique_VAQ_Mont_St-Hilaire%29.JPG/420px-%2770_Plymouth_Barracuda_%28%2711_Auto_classique_VAQ_Mont_St-Hilaire%29.JPG',
index: 16,
Acceleration: 8.0,
Year: '1970-01-01',
Expand All @@ -1194,7 +1211,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: null,
Name: 'ford mustang boss 302',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/1970_Ford_Mustang_Boss_302_%2815863840731%29.jpg/420px-1970_Ford_Mustang_Boss_302_%2815863840731%29.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/1970_Ford_Mustang_Boss_302_%2815863840731%29.jpg/420px-1970_Ford_Mustang_Boss_302_%2815863840731%29.jpg',
index: 17,
Acceleration: 8.0,
Year: '1970-01-01',
Expand All @@ -1207,7 +1225,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 15.0,
Name: 'chevrolet monte carlo',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Chevrolet_Monte_Carlo_1970_P6170033.jpg/420px-Chevrolet_Monte_Carlo_1970_P6170033.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Chevrolet_Monte_Carlo_1970_P6170033.jpg/420px-Chevrolet_Monte_Carlo_1970_P6170033.jpg',
index: 18,
Acceleration: 9.5,
Year: '1970-01-01',
Expand All @@ -1220,7 +1239,8 @@ namespace Data {
Origin: 'USA',
Miles_per_Gallon: 14.0,
Name: 'buick estate wagon (sw)',
Image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/1987_Buick_Electra_Estate_a_station_wagon_at_2019_AACA_Hershey_meet_1of3.jpg/420px-1987_Buick_Electra_Estate_a_station_wagon_at_2019_AACA_Hershey_meet_1of3.jpg',
Image:
'https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/1987_Buick_Electra_Estate_a_station_wagon_at_2019_AACA_Hershey_meet_1of3.jpg/420px-1987_Buick_Electra_Estate_a_station_wagon_at_2019_AACA_Hershey_meet_1of3.jpg',
index: 19,
Acceleration: 10.0,
Year: '1970-01-01',
Expand Down
11 changes: 6 additions & 5 deletions packages/datagrid/src/asynccellrenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
| The full license is in the file LICENSE, distributed with this software.
|----------------------------------------------------------------------------*/

import { CellRenderer } from "./cellrenderer";
import { GraphicsContext } from "./graphicscontext";
import { CellRenderer } from './cellrenderer';
import { GraphicsContext } from './graphicscontext';

/**
* An object which renders the cells of a data grid asynchronously.
Expand All @@ -21,7 +21,6 @@ import { GraphicsContext } from "./graphicscontext";
* See `ImageRenderer` for an example of an asynchronous renderer.
*/
export abstract class AsyncCellRenderer extends CellRenderer {

/**
* Whether the renderer is ready or not for that specific config.
* If it's not ready, the datagrid will paint the placeholder using `paintPlaceholder`.
Expand All @@ -47,6 +46,8 @@ export abstract class AsyncCellRenderer extends CellRenderer {
*
* @param config - The configuration data for the cell.
*/
abstract paintPlaceholder(gc: GraphicsContext, config: CellRenderer.CellConfig): void;

abstract paintPlaceholder(
gc: GraphicsContext,
config: CellRenderer.CellConfig
): void;
}
14 changes: 7 additions & 7 deletions packages/datagrid/src/imagerenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { CellRenderer } from './cellrenderer';

import { GraphicsContext } from './graphicscontext';


export type SizingMode = 'fit' | 'fill' | 'original';

/**
Expand Down Expand Up @@ -52,7 +51,9 @@ export class ImageRenderer extends AsyncCellRenderer {
* @returns Whether the renderer is ready for this config or not.
*/
isReady(config: CellRenderer.CellConfig): boolean {
return !config.value || ImageRenderer.dataCache.get(config.value) !== undefined;
return (
!config.value || ImageRenderer.dataCache.get(config.value) !== undefined
);
}

/**
Expand Down Expand Up @@ -141,8 +142,8 @@ export class ImageRenderer extends AsyncCellRenderer {
const textY = config.y + config.height / 2;

// Draw the placeholder.
gc.fillStyle = "black"; // TODO Make this part of the cell config
gc.fillText("loading...", textX, textY); // TODO Make this "loading..." part of the cell config
gc.fillStyle = 'black'; // TODO Make this part of the cell config
gc.fillText('loading...', textX, textY); // TODO Make this "loading..." part of the cell config
}

/**
Expand All @@ -165,11 +166,10 @@ export class ImageRenderer extends AsyncCellRenderer {
return this.drawPlaceholder(gc, config);
}

const fitHeight = (img.height / img.width) * config.width;
switch (this.sizingMode) {
case 'fit':
const newHeight = (img.height / img.width) * config.width;

gc.drawImage(img, config.x, config.y, config.width, newHeight);
gc.drawImage(img, config.x, config.y, config.width, fitHeight);
break;
case 'fill':
gc.drawImage(img, config.x, config.y, config.width, config.height);
Expand Down

0 comments on commit afb882f

Please sign in to comment.