Skip to content

Commit b52c15a

Browse files
committed
new gold dust theme + graph theme configurations
1 parent 0ef054e commit b52c15a

10 files changed

Lines changed: 663 additions & 519 deletions

File tree

docs/src/app.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ <h3 class="font-semibold text-lg text-gray-800 dark:text-slate-200 mb-2">On this
5151
<option value="light">Long Light</option>
5252
<option value="dark">Long Dark</option>
5353
<option value="cosmic-dark">Cosmic Dark</option>
54+
<option value="gold-dust">Gold Dust</option>
5455
</select>
5556
</div>
5657
<long-spreadsheet [data]="initialData" [columnConfig]="columnConfig" [theme]="spreadsheetTheme()"

docs/src/app.component.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { ChangeDetectionStrategy, Component, signal, inject, Renderer2, computed
22
import { DOCUMENT } from '@angular/common';
33
import { SpreadsheetComponent } from '@longtable/angular-spreadsheet';
44
import { Cell, ColumnConfig, DropdownOption, SpreadsheetTheme } from '@longtable/angular-spreadsheet';
5-
import { longLight, longDark, cosmicDark } from '@longtable/angular-spreadsheet';
5+
import { longLight, longDark, cosmicDark, goldDust } from '@longtable/angular-spreadsheet';
66
import { SafeHtmlPipe } from './safe-html.pipe';
77

88
declare var marked: { parse: (markdown: string) => string };
@@ -53,14 +53,15 @@ export class AppComponent implements OnInit {
5353
]
5454
);
5555

56-
selectedSpreadsheetThemeName = signal<'light' | 'dark' | 'cosmic-dark'>('dark');
56+
selectedSpreadsheetThemeName = signal<'light' | 'dark' | 'cosmic-dark' | 'gold-dust'>('dark');
5757

58-
spreadsheetTheme = computed<SpreadsheetTheme | null>(() => {
58+
spreadsheetTheme = computed<SpreadsheetTheme>(() => {
5959
switch (this.selectedSpreadsheetThemeName()) {
6060
case 'light': return longLight;
6161
case 'dark': return longDark;
6262
case 'cosmic-dark': return cosmicDark;
63-
default: return null;
63+
case 'gold-dust': return goldDust;
64+
default: return longDark;
6465
}
6566
});
6667

@@ -74,7 +75,7 @@ export class AppComponent implements OnInit {
7475

7576
effect(() => {
7677
const themeName = this.selectedSpreadsheetThemeName();
77-
if (themeName === 'dark' || themeName === 'cosmic-dark') {
78+
if (themeName === 'dark' || themeName === 'cosmic-dark' || themeName === 'gold-dust') {
7879
this.renderer.addClass(this.document.documentElement, 'dark');
7980
} else {
8081
this.renderer.removeClass(this.document.documentElement, 'dark');
@@ -111,7 +112,7 @@ export class AppComponent implements OnInit {
111112
}
112113

113114
onThemeChange(event: Event) {
114-
const value = (event.target as HTMLSelectElement).value as 'light' | 'dark' | 'cosmic-dark';
115+
const value = (event.target as HTMLSelectElement).value as 'light' | 'dark' | 'cosmic-dark' | 'gold-dust';
115116
this.selectedSpreadsheetThemeName.set(value);
116117
}
117118

longtable/src/lib/components/correlation-analysis/correlation-analysis.component.ts

Lines changed: 137 additions & 137 deletions
Large diffs are not rendered by default.

longtable/src/lib/components/distribution-analysis/distribution-analysis.component.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ChangeDetectionStrategy, Component, computed, input, effect, viewChild, ElementRef, ChangeDetectorRef, inject, WritableSignal, signal } from '@angular/core';
22
import { CommonModule } from '@angular/common';
33
import { FormsModule } from '@angular/forms';
4-
import { Cell, AnalysisType, AnalysisOption, DropdownOption, SavedDistributionAnalysisState, ColumnConfig } from '../../models/spreadsheet.model';
4+
import { Cell, AnalysisType, AnalysisOption, DropdownOption, SavedDistributionAnalysisState, ColumnConfig, SpreadsheetTheme } from '../../models/spreadsheet.model';
55
import {
66
select,
77
max,
@@ -38,6 +38,7 @@ export class DistributionAnalysisComponent {
3838
initialAnalysisField = input<number | null>(null);
3939
state = input.required<WritableSignal<SavedDistributionAnalysisState>>();
4040
columnConfig = input.required<ColumnConfig[]>();
41+
theme = input.required<SpreadsheetTheme>();
4142

4243
private chartContainer = viewChild<ElementRef<HTMLDivElement>>('distributionChartContainer');
4344
private tooltip = viewChild<ElementRef<HTMLDivElement>>('statsTooltip');
@@ -299,7 +300,7 @@ export class DistributionAnalysisComponent {
299300
if (data.length === 0) return;
300301

301302
const isDark = document.documentElement.classList.contains('dark');
302-
const textColor = isDark ? '#94a3b8' : '#64748b'; // More visible
303+
const textColor = this.theme().colors.graphSecondary;
303304
const barStep = 25;
304305
const margin = { top: 5, right: 20, bottom: 60, left: 120 };
305306
const height = data.length * barStep;
@@ -359,7 +360,7 @@ export class DistributionAnalysisComponent {
359360

360361
svg.selectAll('.bar').data(data).enter().append('rect')
361362
.attr('class', 'bar').attr('x', x(0)).attr('y', d => y(d.key)!)
362-
.attr('width', d => x(d.value) - x(0)).attr('height', y.bandwidth()).attr('fill', '#3b82f6')
363+
.attr('width', d => x(d.value) - x(0)).attr('height', y.bandwidth()).attr('fill', this.theme().colors.graphPrimary)
363364
.on('mouseover', (event, d) => {
364365
select(event.currentTarget).style('opacity', '0.85');
365366
tooltip.style('opacity', '1').html(`<strong>${d.key}</strong><br/>Count: ${d.value}`);
@@ -393,7 +394,7 @@ export class DistributionAnalysisComponent {
393394
const series = stack().keys(stackKeys)(data as any);
394395

395396
const isDark = document.documentElement.classList.contains('dark');
396-
const textColor = isDark ? '#94a3b8' : '#64748b'; // More visible
397+
const textColor = this.theme().colors.graphSecondary;
397398
const barStep = 30;
398399
const margin = { top: 5, right: 120, bottom: 60, left: 120 };
399400
const height = data.length * barStep;
@@ -502,8 +503,7 @@ export class DistributionAnalysisComponent {
502503
}
503504

504505
private _renderGradientLegend(svg: Selection<SVGGElement, unknown, null, undefined>, colorScale: ScaleSequentialType<string>, legendX: number, legendY: number, height: number, title: string) {
505-
const isDark = document.documentElement.classList.contains('dark');
506-
const textColor = isDark ? '#94a3b8' : '#64748b';
506+
const textColor = this.theme().colors.graphSecondary;
507507
const [min, max] = colorScale.domain();
508508
if (min === undefined || max === undefined) return;
509509
const legendId = `legend-gradient-${Math.random().toString(36).substring(2, 9)}`;

0 commit comments

Comments
 (0)