Skip to content

Commit

Permalink
Merge pull request #15 from rayshader/9-change-default-settings
Browse files Browse the repository at this point in the history
Issue 9 - Change default settings
  • Loading branch information
poirierlouis authored Feb 4, 2024
2 parents 7886e3e + 0738916 commit 2b0efbd
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface ThemeItem {
export class NDBIdeThemeComponent {

readonly themes: ThemeItem[] = [
{isSelected: true, value: IDETheme.vanilla, name: 'Vanilla'},
{isSelected: true, value: IDETheme.legacy, name: 'Legacy'},
{isSelected: false, value: IDETheme.vscode, name: 'VS Code · Modern'},
{isSelected: false, value: IDETheme.intellij, name: 'IntelliJ · Dracula'},
];
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/spans/type-span/type-span.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class TypeSpanComponent {
isEmpty: boolean = false;

protected readonly syntax$: Observable<number>;
protected readonly vanilla: number = CodeSyntax.vanilla + 1;
protected readonly vanilla: number = CodeSyntax.pseudocode + 1;
protected readonly redscript: number = CodeSyntax.redscript + 1;
protected readonly cpp: number = CodeSyntax.cppRED4ext + 1;

Expand Down
8 changes: 4 additions & 4 deletions src/app/pages/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ interface AItem<T> {
export class SettingsComponent implements OnInit {

readonly clipboardOptions: AItem<CodeSyntax>[] = [
{value: CodeSyntax.redscript, name: 'Red · Scripts', disabled: true},
{value: CodeSyntax.redscript, name: 'Redscript', disabled: true},
{value: CodeSyntax.lua, name: 'Lua · CET', disabled: false},
{value: CodeSyntax.cppRedLib, name: 'C++ · RedLib', disabled: false},
];

readonly codeOptions: AItem<CodeSyntax>[] = [
{value: CodeSyntax.vanilla, name: 'Vanilla', disabled: false},
{value: CodeSyntax.redscript, name: 'Red · Scripts', disabled: false},
{value: CodeSyntax.pseudocode, name: 'Pseudocode · Legacy', disabled: false},
{value: CodeSyntax.redscript, name: 'Redscript', disabled: false},
{value: CodeSyntax.cppRED4ext, name: 'C++ · RED4ext / RedLib', disabled: false}
];

Expand All @@ -49,7 +49,7 @@ export class SettingsComponent implements OnInit {
readonly highlightEmptyObject: FormControl<boolean | null> = new FormControl(true);
readonly showEmptyAccordion: FormControl<boolean | null> = new FormControl(false);
readonly mergeObject: FormControl<boolean | null> = new FormControl(false);
readonly clipboardSyntax: FormControl<CodeSyntax | null> = new FormControl(CodeSyntax.redscript);
readonly clipboardSyntax: FormControl<CodeSyntax | null> = new FormControl(CodeSyntax.lua);
readonly codeSyntax: FormControl<CodeSyntax | null> = new FormControl(CodeSyntax.redscript);

constructor(private readonly settingsService: SettingsService,
Expand Down
2 changes: 1 addition & 1 deletion src/app/pipes/ndb-format-code.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class NDBFormatCodePipe implements PipeTransform {
transform(type: RedTypeAst, syntax: CodeSyntax): string {
syntax = syntax - 1;
switch (syntax) {
case CodeSyntax.vanilla:
case CodeSyntax.pseudocode:
if (type.flag === RedTemplateDef.ref) {
return 'handle';
} else if (type.flag === RedTemplateDef.wref) {
Expand Down
10 changes: 5 additions & 5 deletions src/shared/services/ide-theme.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {takeUntilDestroyed} from "@angular/core/rxjs-interop";
import {LazyLoaderService} from "./lazy-loader.service";

export enum IDETheme {
vanilla,
legacy,
vscode,
intellij
}
Expand All @@ -20,10 +20,10 @@ export interface IDEThemeChanged {
})
export class IDEThemeService {
private theme: BehaviorSubject<IDEThemeChanged> = new BehaviorSubject<IDEThemeChanged>({
old: IDETheme.vanilla,
current: IDETheme.vanilla,
old: IDETheme.vscode,
current: IDETheme.vscode,
});
private currentTheme: IDETheme = IDETheme.vanilla;
private currentTheme: IDETheme = IDETheme.vscode;
private isDarkLoaded: boolean = false;

constructor(private readonly themeService: ThemeService,
Expand All @@ -32,7 +32,7 @@ export class IDEThemeService {
let ideTheme: IDETheme;

if (!localIdeTheme) {
ideTheme = IDETheme.vanilla;
ideTheme = IDETheme.vscode;
} else {
ideTheme = +localIdeTheme;
}
Expand Down
23 changes: 12 additions & 11 deletions src/shared/services/settings.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ describe('SettingsService', () => {
showDocumentation: true,
highlightEmptyObject: true,
showEmptyAccordion: false,
mergeObject: false,
mergeObject: true,
tabsWidth: 320,
isBarPinned: true,
clipboardSyntax: CodeSyntax.lua,
codeSyntax: CodeSyntax.vanilla
codeSyntax: CodeSyntax.redscript
});
});

Expand All @@ -51,11 +51,11 @@ describe('SettingsService', () => {
'show-documentation': false,
'highlight-empty-object': true,
'show-empty-accordion': true,
'merge-object': true,
'merge-object': false,
'tabs-width': 400,
'is-bar-pinned': false,
'clipboard-syntax': CodeSyntax.lua,
'code-syntax': CodeSyntax.redscript
'code-syntax': CodeSyntax.pseudocode
});

// WHEN
Expand All @@ -72,11 +72,11 @@ describe('SettingsService', () => {
showDocumentation: false,
highlightEmptyObject: true,
showEmptyAccordion: true,
mergeObject: true,
mergeObject: false,
tabsWidth: 400,
isBarPinned: false,
clipboardSyntax: CodeSyntax.lua,
codeSyntax: CodeSyntax.redscript
codeSyntax: CodeSyntax.pseudocode
});
});

Expand All @@ -89,11 +89,11 @@ describe('SettingsService', () => {
'show-documentation': true,
'highlight-empty-object': false,
'show-empty-accordion': false,
'merge-object': false,
'merge-object': true,
'tabs-width': 500,
'is-bar-pinned': true,
'clipboard-syntax': CodeSyntax.cppRedLib,
'code-syntax': CodeSyntax.redscript
'code-syntax': CodeSyntax.pseudocode
});

// WHEN
Expand Down Expand Up @@ -137,11 +137,11 @@ describe('SettingsService', () => {
showDocumentation: true,
highlightEmptyObject: false,
showEmptyAccordion: false,
mergeObject: false,
mergeObject: true,
tabsWidth: 500,
isBarPinned: true,
clipboardSyntax: CodeSyntax.cppRedLib,
codeSyntax: CodeSyntax.redscript
codeSyntax: CodeSyntax.pseudocode
});
});

Expand All @@ -153,10 +153,11 @@ describe('SettingsService', () => {
{name: 'showDocumentation', key: 'show-documentation', change: false, expect: 'false'},
{name: 'highlightEmptyObject', key: 'highlight-empty-object', change: false, expect: 'false'},
{name: 'showEmptyAccordion', key: 'show-empty-accordion', change: true, expect: 'true'},
{name: 'mergeObject', key: 'merge-object', change: false, expect: 'false'},
{name: 'tabsWidth', key: 'tabs-width', change: 400, expect: '400'},
{name: 'isBarPinned', key: 'is-bar-pinned', change: false, expect: 'false'},
{name: 'clipboard', key: 'clipboard-syntax', change: CodeSyntax.lua, expect: CodeSyntax.lua.toString()},
{name: 'code', key: 'code-syntax', change: CodeSyntax.vanilla, expect: CodeSyntax.vanilla.toString()},
{name: 'code', key: 'code-syntax', change: CodeSyntax.pseudocode, expect: CodeSyntax.pseudocode.toString()},
];

beforeAll(() => {
Expand Down
10 changes: 5 additions & 5 deletions src/shared/services/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface Settings {
}

export enum CodeSyntax {
vanilla,
pseudocode,
redscript,
lua,
cppRED4ext,
Expand All @@ -36,11 +36,11 @@ export class SettingsService {
private readonly showDocumentationSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
private readonly highlightEmptyObjectSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
private readonly showEmptyAccordionSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
private readonly mergeObjectSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
private readonly mergeObjectSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
private readonly tabsWidthSubject: BehaviorSubject<number> = new BehaviorSubject<number>(320);
private readonly isBarPinnedSubject: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
private readonly clipboardSubject: BehaviorSubject<CodeSyntax> = new BehaviorSubject<CodeSyntax>(CodeSyntax.lua);
private readonly codeSubject: BehaviorSubject<CodeSyntax> = new BehaviorSubject<CodeSyntax>(CodeSyntax.vanilla);
private readonly codeSubject: BehaviorSubject<CodeSyntax> = new BehaviorSubject<CodeSyntax>(CodeSyntax.redscript);

/**
* Whether this application is used for the first time on this device?
Expand Down Expand Up @@ -112,11 +112,11 @@ export class SettingsService {
const showDocumentation: boolean = (localStorage.getItem('show-documentation') ?? 'true') === 'true';
const highlightEmptyObject: boolean = (localStorage.getItem('highlight-empty-object') ?? 'true') === 'true';
const showEmptyAccordion: boolean = (localStorage.getItem('show-empty-accordion') ?? 'false') === 'true';
const mergeObject: boolean = (localStorage.getItem('merge-object') ?? 'false') === 'true';
const mergeObject: boolean = (localStorage.getItem('merge-object') ?? 'true') === 'true';
const tabsWidth: number = +(localStorage.getItem('tabs-width') ?? '320');
const isBarPinned: boolean = (localStorage.getItem('is-bar-pinned') ?? 'true') === 'true';
const clipboard: string = localStorage.getItem('clipboard-syntax') ?? CodeSyntax.lua.toString();
const code: string = localStorage.getItem('code-syntax') ?? CodeSyntax.vanilla.toString();
const code: string = localStorage.getItem('code-syntax') ?? CodeSyntax.redscript.toString();

this.ignoreDuplicateSubject.next(ignoreDuplicate);
this.scriptOnlySubject.next(scriptOnly);
Expand Down
6 changes: 3 additions & 3 deletions src/styles/ide/_vanilla.scss → src/styles/ide/_legacy.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@use 'sass:color';

@mixin ide-vanilla-theme($is-light: true) {
@mixin ide-legacy-theme($is-light: true) {
@if $is-light {
@import url('https://fonts.googleapis.com/css2?family=Fira+Code&display=swap');

.ide-vanilla-theme {
.ide-legacy-theme {
--ndb-ide-typography-family: #{'Fira Code', monospace};
--ndb-ide-typography-size: 1rem;

Expand All @@ -25,7 +25,7 @@
--ndb-ide-primitive-type: var(--ndb-ide-language);
}
} @else {
.ide-vanilla-theme {
.ide-legacy-theme {
&.dark-theme {
--ndb-ide-background: #2B2B2B;
--ndb-ide-toolbar: #161B22;
Expand Down
4 changes: 2 additions & 2 deletions src/styles/rd-dark-ide-theme.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use './ide/vanilla' as *;
@use './ide/legacy' as *;
@use './ide/vscode' as *;
@use './ide/intellij' as *;

@include ide-vanilla-theme($is-light: false);
@include ide-legacy-theme($is-light: false);
@include ide-vscode-theme($is-light: false);
@include ide-intellij-theme($is-light: false);
4 changes: 2 additions & 2 deletions src/styles/rd-light-ide-theme.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@use './ide/mixins' as *;
@use './ide/vanilla' as *;
@use './ide/legacy' as *;
@use './ide/vscode' as *;
@use './ide/intellij' as *;

@include rd-ide-typography();
@include rd-ide-background();
@include rd-ide-theme();

@include ide-vanilla-theme($is-light: true);
@include ide-legacy-theme($is-light: true);
@include ide-vscode-theme($is-light: true);
@include ide-intellij-theme($is-light: true);

0 comments on commit 2b0efbd

Please sign in to comment.