Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

finos/a11y-theme-builder#1058: fixing getDefaultName and getColorName… #164

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The following is a tutorial of how to use this SDK in order to generate code whi
// The 1st parameter is the name of the color (e.g. "blue")
// The 2nd parameter is the hex value for the color (e.g. "#E2F3FF")
const blue = myDesignSystem.atoms.colorPalette.addColor("blue", "#E2F3FF");
const red = myDesignSystem.atoms.colorPalette.addColor("red", "#DC143C);
const red = myDesignSystem.atoms.colorPalette.addColor("red", "#DC143C");
const green = myDesignSystem.atoms.colorPalette.addColor("green", "#32CD32");
```

Expand Down Expand Up @@ -157,10 +157,10 @@ The following is a tutorial of how to use this SDK in order to generate code whi

Now that the default color theme has been initialized, everything else should now be enabled including:

* All other atoms (e.g. `myTheme.atoms.gridSettings.isEnabled() is true`)
* All molecules (i.e. `myTheme.molecules.isEnabled() is true`)
* All organisms (i.e. `myTheme.organisms.isEnabled() is true`)
* Code generation (i.e. `myTheme.code.isEnabled() is true`)
* All other atoms (e.g. `myDesignSystem.atoms.gridSettings.isEnabled() is true`)
* All molecules (i.e. `myDesignSystem.molecules.isEnabled() is true`)
* All organisms (i.e. `myDesignSystem.organisms.isEnabled() is true`)
* Code generation (i.e. `myDesignSystem.code.isEnabled() is true`)

All of these remaining properties are either optional (i.e. are not required to have a value) or have a default value. The `listProperties` method of a design system may be used as shown below to list all properties of a design system, along with it's key, whether or not it is required, and the default value (or undefined if it has no default value).

Expand Down
2 changes: 1 addition & 1 deletion src/atoms/colorPalette.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ColorPalette extends Atom implements IColorPalette {
* @returns Return a list of string names for the colors.
*/
public getColorNames(): string[] {
return Object.keys(this.colors);
return this.colors.keys() ? Array.from(this.colors.keys()) : [];
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/atoms/colorThemes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,6 @@ export class ColorTheme extends Node implements IColorTheme {
this.gradientHeaderText = new GradientColors2(this, "Gradient Header Text", selOpts);
// Accent color
this.accent = new PropertyColorShade("Accent", true, this, opts);
this.addTheme = new PropertyBoolean("Add Theme", false, this);
this.addTheme.addDependency(this);
this.accent.addDependency(this.primary);
this.addTheme = new PropertyBoolean("Add Theme", false, this);
this.addTheme.addDependency(this);
Expand Down
4 changes: 4 additions & 0 deletions test/dotest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ async function test() {
console.log("TEST: Adding new color after primary was selected");
colorPalette.addColor("newColor","#0047AB");
assert(ct.primary.getValue() !== undefined, `Adding a color to the theme should not change the primary color`);
const defaultColorName = colorPalette.getDefaultColorName();
assert(!!defaultColorName, `Retrieving default color name from populated palette should be non-empty`);
const colors = colorPalette.getColorNames();
assert((colors && colors.length > 0), `Retrieving color names from populated palette should be non-empty`);
console.log("TEST: Added new color after primary was selected");

// list all properties
Expand Down