Skip to content

Commit

Permalink
Fix cobweb imports when generating others mods, improved theme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal-Spider committed May 24, 2024
1 parent b3d8899 commit 3662010
Show file tree
Hide file tree
Showing 20 changed files with 381 additions and 354 deletions.
72 changes: 0 additions & 72 deletions docs/chunk-3JBBZPQA.js

This file was deleted.

77 changes: 77 additions & 0 deletions docs/chunk-M6MSLSN4.js

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions docs/chunk-62OCQJYL.js → docs/chunk-P5DAIAFL.js

Large diffs are not rendered by default.

72 changes: 72 additions & 0 deletions docs/chunk-SR3QQFLV.js

Large diffs are not rendered by default.

77 changes: 0 additions & 77 deletions docs/chunk-VDJZU3TS.js

This file was deleted.

6 changes: 3 additions & 3 deletions docs/index.html

Large diffs are not rendered by default.

79 changes: 0 additions & 79 deletions docs/main-K6RLGV6W.js

This file was deleted.

79 changes: 79 additions & 0 deletions docs/main-X3CQF2GV.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/styles-CREJOTC3.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/styles-D3QGXILZ.css

This file was deleted.

11 changes: 4 additions & 7 deletions src/app/core/redux/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,10 @@ export const coreFeature = createFeature({
loadingType: 'query' as ProgressBarMode
};
}),
on(saveLoadingType, (state, {loadingType, force}) => {
console.log(state, loadingType, force);
return {
...state,
loadingType: !force && state.callCounter > 0 && state.loadingType === 'determinate' ? 'determinate' : loadingType
};
}),
on(saveLoadingType, (state, {loadingType, force}) => ({
...state,
loadingType: !force && state.callCounter > 0 && state.loadingType === 'determinate' ? 'determinate' : loadingType
})),
on(saveProgress, (state, {progress}) => ({
...state,
progress
Expand Down
6 changes: 3 additions & 3 deletions src/app/feature/frame/component/header/header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

header {
display: flex;
background-color: $purple-700;
background-color: $cn-color-700;
color: #cccccc;
height: 5rem;
padding: 1rem;
Expand All @@ -28,7 +28,7 @@

> li {
transition-duration: 0.2s;
border-bottom: 0 solid $purple-a700;
border-bottom: 0 solid $cn-color-a700;
border-radius: 0.25rem;
white-space: nowrap;

Expand Down Expand Up @@ -182,7 +182,7 @@
}

&:not(:last-child) {
border-bottom: 1px solid $purple-a700;
border-bottom: 1px solid $cn-color-a700;
padding-bottom: 0.5rem;
}

Expand Down
11 changes: 8 additions & 3 deletions src/app/feature/generator/class/generator-validators.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ export class GeneratorValidators {
* @readonly
* @type {ValidatorFn[]}
*/
public static readonly modTitle: ValidatorFn[] = [Validators.required, Validators.minLength(this.modIdMinLength), Validators.maxLength(this.modIdMaxLength)];
public static readonly modTitle: ValidatorFn[] = [
Validators.required,
Validators.minLength(this.modIdMinLength),
Validators.maxLength(this.modIdMaxLength),
GeneratorValidators.notMatch('cobweb')
];

/**
* Checks whether the value does not include any of the given values.
Expand All @@ -51,7 +56,7 @@ export class GeneratorValidators {
*/
public static notInclude(...values: string[]): ValidatorFn {
return control => {
if (control.value && typeof control.value === 'string' && values.some(value => control.value.toLowerCase().includes(value.toLowerCase()))) {
if (control.value && typeof control.value === 'string' && values.some(value => control.value.toLowerCase().trim().includes(value.toLowerCase().trim()))) {
return {notInclude: true};
}
return null;
Expand All @@ -69,7 +74,7 @@ export class GeneratorValidators {
*/
public static notMatch(...values: string[]): ValidatorFn {
return control => {
if (control.value && values.some(value => control.value.toLowerCase() === value.toLowerCase())) {
if (control.value && values.some(value => control.value.toLowerCase().trim() === value.toLowerCase().trim())) {
return {notMatch: true};
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ export class GeneratorFormComponent extends FormComponent<SkeletonForm> implemen
'model',
'services',
'META-INF'
)
),
Validators.pattern('^([a-z]+(\.|_))*[a-z]+$')
]);
this.form.controls.authors.setValidators([Validators.required, GeneratorValidators.notInclude(...TEMPLATE_AUTHORS)]);
this.form.controls.githubUser.setValidators([Validators.required, GeneratorValidators.notMatch(TEMPLATE_GITHUB_USER)]);
Expand All @@ -200,7 +201,7 @@ export class GeneratorFormComponent extends FormComponent<SkeletonForm> implemen
*/
protected override initForm(): FormType<SkeletonForm> {
return {
minecraftVersion: new FormControl('1.20.4', {
minecraftVersion: new FormControl('' as MinecraftVersion, {
nonNullable: true,
validators: Validators.required
}),
Expand Down
41 changes: 38 additions & 3 deletions src/app/feature/generator/redux/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ export class GeneratorEffects {
const rootChange: Change = [root, modIdKebab];
const modIdChange: Change = [TEMPLATE_MOD_ID, modId];
const modIdKebabChange: Change = [TEMPLATE_MOD_ID_KEBAB, modIdKebab];
const modTitleChange: Change = [TEMPLATE_MOD_TITLE, modTitle];
const groupChange: Change = [TEMPLATE_GROUP, group, othersMod];
const modTitleChange: Change = [TEMPLATE_MOD_TITLE, modTitle.trim()];
const groupChange: Change = [new RegExp(`${TEMPLATE_GROUP.replace('.', '\\.')}(?!\\.cobweb\\.)`, 'g'), group, othersMod];
const groupPathChange: Change = [TEMPLATE_GROUP_PATH, group.replaceAll('.', '/'), othersMod];
const fcapChange: Change = [/.*f(orge-)?c(onfig-)?a(pi-)?p(ort)?.*\n/g, '', noConfig];
const loaderChanges = this.loadersChanges(excludedLoaders);
Expand Down Expand Up @@ -236,7 +236,7 @@ export class GeneratorEffects {
loadingType: 'indeterminate',
force: true
}));
return zip;
return this.removeEmptyDirs(zip);
}

/**
Expand Down Expand Up @@ -330,6 +330,41 @@ export class GeneratorEffects {
return changes.reduce((content, [search, replace, flag]) => flag ?? true ? content[typeof search === 'string' ? 'replaceAll' : 'replace'](search, replace) : content, value);
}

/**
* Removes all empty directories.
*
* @private
* @param {JSZip} zip
* @returns {JSZip}
*/
private removeEmptyDirs(zip: JSZip): JSZip {
for (const dir of zip.filter((path, entry) => entry.dir && this.isEmptyDir(zip.files, path)).map(entry => entry.name)) {
zip.remove(dir);
}
return zip;
}

/**
* Checks whether the given directory is empty.
*
* @private
* @param {Record<string, JSZipObject>} files
* @param {string} dir
* @returns {boolean}
*/
private isEmptyDir(files: Record<string, JSZipObject>, dir: string) {
for (const [path, entry] of Object.entries(files)) {
if (entry.dir) {
if (path.startsWith(dir) && path !== dir) {
return false;
}
} else if (path.startsWith(dir)) {
return false;
}
}
return true;
}

/**
* Downloads the given `file`.
*
Expand Down
2 changes: 1 addition & 1 deletion src/styles.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@use "@angular/material" as material;
@import "variables", "grids";
@import "override/card", "override/checkbox", "override/divider", "override/input", "override/menu", "override/stepper", "override/select", "override/toggle";
@import "override/button", "override/card", "override/checkbox", "override/divider", "override/input", "override/menu", "override/stepper", "override/select", "override/toggle";

* {
box-sizing: border-box;
Expand Down
4 changes: 4 additions & 0 deletions src/styles/override/button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.mdc-button:hover {
// background-color: inherit !important;
filter: brightness(1.2) !important;
}
2 changes: 1 addition & 1 deletion src/styles/override/divider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.mat-divider {
border-top-width: 2px !important;
border-color: $purple-500 !important;
border-color: $cn-color-a700 !important;
border-radius: $separator-border-radius;

&.mat-divider-vertical {
Expand Down
13 changes: 12 additions & 1 deletion src/styles/override/toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,16 @@
}

.mdc-switch.mdc-switch--selected:enabled .mdc-switch__icon {
fill: white !important;
fill: black !important;
}

.mat-mdc-slide-toggle .mdc-label {
color: #eeeeee !important;
}

.mdc-switch.mdc-switch--unselected:hover,
.mdc-switch.mdc-switch--unselected + .mdc-label:hover,
.mdc-switch.mdc-switch--selected.mdc-switch--checked:hover {
background-color: inherit !important;
filter: brightness(1.2) !important;
}
158 changes: 66 additions & 92 deletions src/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,58 @@

@include material.core();

$purple-50: #eeeeee;
$purple-100: #eeeeee;
$purple-200: #8a22f1;
$purple-300: #8a22f1;
$purple-400: #eeeeee;
$purple-500: #8a22f1;
$purple-600: #c071f5;
$purple-700: #1f1b3b;
$purple-800: #eeeeee;
$purple-900: #eeeeee;
$cn-color-50: #eeeeee;
$cn-color-100: #eeeeee;
$cn-color-200: #c071f5;
$cn-color-300: #c071f5;
$cn-color-400: #eeeeee;
$cn-color-500: #c071f5;
$cn-color-600: #8458b6;
$cn-color-700: #1f1b3b;
$cn-color-800: #eeeeee;
$cn-color-900: #eeeeee;

$purple-a50: #eeeeee;
$purple-a100: #eeeeee;
$purple-a200: #eeeeee;
$purple-a300: #eeeeee;
$purple-a400: #eeeeee;
$purple-a500: #8a22f1;
$purple-a600: #eeeeee;
$purple-a700: #c071f5;
$purple-a800: #eeeeee;
$purple-a900: #eeeeee;
$cn-color-a50: #eeeeee;
$cn-color-a100: #eeeeee;
$cn-color-a200: #eeeeee;
$cn-color-a300: #eeeeee;
$cn-color-a400: #eeeeee;
$cn-color-a500: #000000;
$cn-color-a600: #eeeeee;
$cn-color-a700: #c071f5;
$cn-color-a800: #eeeeee;
$cn-color-a900: #eeeeee;

$purple-palette: (
50: $purple-50,
100: $purple-100,
200: $purple-200,
300: $purple-300,
400: $purple-400,
500: $purple-500,
600: $purple-600,
700: $purple-700,
800: $purple-800,
900: $purple-900,
$cn-color-palette: (
50: $cn-color-50,
100: $cn-color-100,
200: $cn-color-200,
300: $cn-color-300,
400: $cn-color-400,
500: $cn-color-500,
600: $cn-color-600,
700: $cn-color-700,
800: $cn-color-800,
900: $cn-color-900,
contrast: (
50: $purple-a50,
100: $purple-a100,
200: $purple-a200,
300: $purple-a300,
400: $purple-a400,
500: $purple-a500,
600: $purple-a600,
700: $purple-a700,
800: $purple-a800,
900: $purple-a900,
50: $cn-color-a50,
100: $cn-color-a100,
200: $cn-color-a200,
300: $cn-color-a300,
400: $cn-color-a400,
500: $cn-color-a500,
600: $cn-color-a600,
700: $cn-color-a700,
800: $cn-color-a800,
900: $cn-color-a900,
),
);

$primary-palette: material.define-palette($purple-palette);
$accent-palette: material.define-palette($purple-palette);
$primary-palette: material.define-palette($cn-color-palette);
$accent-palette: material.define-palette($cn-color-palette);
$warn-palette: material.define-palette(material.$red-palette);

$cn-light-theme: material.define-light-theme(
$cn-dark-theme: material.define-dark-theme(
(
color: (
primary: $primary-palette,
Expand All @@ -67,52 +67,26 @@ $cn-light-theme: material.define-light-theme(
)
);

$cn-dark-theme: material.define-dark-theme(
(
color: (
primary: $primary-palette,
accent: $accent-palette,
warn: $warn-palette,
),
)
);

@include material.core-theme($cn-light-theme);
@include material.sidenav-theme($cn-light-theme);
@include material.icon-theme($cn-light-theme);
@include material.button-theme($cn-light-theme);
@include material.fab-theme($cn-light-theme);
@include material.form-field-theme($cn-light-theme);
@include material.stepper-theme($cn-light-theme);
@include material.checkbox-theme($cn-light-theme);
@include material.slide-toggle-theme($cn-light-theme);
@include material.input-theme($cn-light-theme);
@include material.select-theme($cn-light-theme);
@include material.progress-bar-theme($cn-light-theme);
@include material.card-theme($cn-light-theme);
@include material.menu-theme($cn-light-theme);
@include material.divider-theme($cn-light-theme);

@media (prefers-color-scheme: dark) {
:root {
color-scheme: dark;
--mdc-elevated-card-container-color: #202020;
--mat-select-panel-background-color: #2b2b2b;
--mat-menu-container-color: #1e1b33;
}
@include material.core-color($cn-dark-theme);
@include material.sidenav-color($cn-dark-theme);
@include material.icon-color($cn-dark-theme);
@include material.button-color($cn-dark-theme);
@include material.fab-color($cn-dark-theme);
@include material.form-field-color($cn-dark-theme);
@include material.stepper-color($cn-dark-theme);
@include material.checkbox-color($cn-dark-theme);
@include material.slide-toggle-color($cn-dark-theme);
@include material.input-color($cn-dark-theme);
@include material.select-color($cn-dark-theme);
@include material.progress-bar-color($cn-dark-theme);
@include material.card-color($cn-dark-theme);
@include material.menu-color($cn-dark-theme);
@include material.divider-color($cn-dark-theme);
:root {
color-scheme: dark;
@include material.core-theme($cn-dark-theme);
@include material.sidenav-theme($cn-dark-theme);
@include material.icon-theme($cn-dark-theme);
@include material.button-theme($cn-dark-theme);
@include material.fab-theme($cn-dark-theme);
@include material.form-field-theme($cn-dark-theme);
@include material.stepper-theme($cn-dark-theme);
@include material.checkbox-theme($cn-dark-theme);
@include material.slide-toggle-theme($cn-dark-theme);
@include material.input-theme($cn-dark-theme);
@include material.select-theme($cn-dark-theme);
@include material.progress-bar-theme($cn-dark-theme);
@include material.card-theme($cn-dark-theme);
@include material.menu-theme($cn-dark-theme);
@include material.divider-theme($cn-dark-theme);
--mdc-elevated-card-container-color: #202020;
--mat-stepper-container-color: #202020;
--mat-select-panel-background-color: #2b2b2b;
--mat-menu-container-color: #1e1b33;
--mdc-form-field-label-text-color: #eeeeee;
}

0 comments on commit 3662010

Please sign in to comment.