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

Init tikui module #10935

Merged
merged 3 commits into from
Sep 29, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package tech.jhipster.lite.generator.client.react.core.domain;

import static tech.jhipster.lite.module.domain.JHipsterModule.*;
import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.COMMON;
import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.REACT;
import static tech.jhipster.lite.module.domain.replacement.ReplacementCondition.always;
import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.*;
import static tech.jhipster.lite.module.domain.replacement.ReplacementCondition.*;

import java.util.function.Consumer;
import tech.jhipster.lite.module.domain.Indentation;
Expand Down Expand Up @@ -51,7 +50,7 @@ public JHipsterModule buildModule(JHipsterModuleProperties properties) {
.addDevDependency(packageName("vite"), COMMON)
.addDependency(packageName("react"), REACT)
.addDependency(packageName("react-dom"), REACT)
.addScript(scriptKey("dev"), scriptCommand("npm-run-all dev:*"))
.addScript(scriptKey("dev"), scriptCommand("npm-run-all --parallel dev:*"))
.addScript(scriptKey("dev:vite"), scriptCommand("vite"))
.addScript(scriptKey("build"), scriptCommand("npm-run-all build:*"))
.addScript(scriptKey("build:tsc"), scriptCommand("tsc"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tech.jhipster.lite.generator.client.tikui.application;

import org.springframework.stereotype.Service;
import tech.jhipster.lite.generator.client.tikui.domain.TikuiModuleFactory;
import tech.jhipster.lite.module.domain.JHipsterModule;
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties;

@Service
public class TikuiApplicationService {

private final TikuiModuleFactory factory = new TikuiModuleFactory();

public JHipsterModule buildModule(JHipsterModuleProperties properties) {
return factory.buildModule(properties);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
package tech.jhipster.lite.generator.client.tikui.domain;

import static tech.jhipster.lite.module.domain.JHipsterModule.*;
import static tech.jhipster.lite.module.domain.npm.JHLiteNpmVersionSource.*;

import java.util.regex.Pattern;
import tech.jhipster.lite.module.domain.JHipsterModule;
import tech.jhipster.lite.module.domain.file.JHipsterDestination;
import tech.jhipster.lite.module.domain.file.JHipsterSource;
import tech.jhipster.lite.module.domain.properties.JHipsterModuleProperties;
import tech.jhipster.lite.module.domain.replacement.RegexNeedleAfterReplacer;
import tech.jhipster.lite.module.domain.replacement.ReplacementCondition;

public class TikuiModuleFactory {

private static final JHipsterSource SOURCE = from("client/tikui");
private static final JHipsterSource STYLE_SOURCE = SOURCE.append("style");

private static final JHipsterDestination STYLE_DESTINATION = to("src/main/style");

private static final String ATOM = "atom";
private static final String ATOM_BUTTON = ATOM + "/button";
private static final String ATOM_INPUT_TEXT = ATOM + "/input-text";
private static final String ATOM_LABEL = ATOM + "/label";
private static final String MOLECULE = "molecule";
private static final String MOLECULE_FIELD = MOLECULE + "/field";
private static final String ORGANISM = "organism";
private static final String ORGANISM_LINES = ORGANISM + "/lines";
private static final String QUARK = "quark";

//@formatter:off
public JHipsterModule buildModule(JHipsterModuleProperties properties) {
return moduleBuilder(properties)
.packageJson()
.addDependency(packageName("@tikui/core"), COMMON)
.addDevDependency(packageName("stylelint"), COMMON)
.addDevDependency(packageName("stylelint-config-concentric-order"), COMMON)
.addDevDependency(packageName("stylelint-config-standard-scss"), COMMON)
.addDevDependency(packageName("stylelint-order"), COMMON)
.addDevDependency(packageName("tikuidoc-tikui"), COMMON)
.addScript(scriptKey("build:tikui"), scriptCommand("tikui-core build"))
.addScript(scriptKey("dev:tikui"), scriptCommand("tikui-core serve"))
.and()
.files()
.add(SOURCE.template("tikuiconfig.json"), to("tikuiconfig.json"))
.add(SOURCE.template(".stylelintrc.json"), to(".stylelintrc.json"))
.batch(STYLE_SOURCE, STYLE_DESTINATION)
.addTemplate("tikui.scss")
.addTemplate("favicon.ico")
.addTemplate("index.pug")
.addTemplate("layout.pug")
.addTemplate("layout-documentation.pug")
.and()
.batch(STYLE_SOURCE.append(ATOM), STYLE_DESTINATION.append(ATOM))
.addTemplate("_atom.scss")
.addTemplate("atom.pug")
.and()
.batch(STYLE_SOURCE.append(ATOM_BUTTON), STYLE_DESTINATION.append(ATOM_BUTTON))
.addTemplate("_button.scss")
.addTemplate("button.code.pug")
.addTemplate("button.md")
.addTemplate("button.mixin.pug")
.addTemplate("button.render.pug")
.and()
.batch(STYLE_SOURCE.append(ATOM_INPUT_TEXT), STYLE_DESTINATION.append(ATOM_INPUT_TEXT))
.addTemplate("_input-text.scss")
.addTemplate("input-text.code.pug")
.addTemplate("input-text.md")
.addTemplate("input-text.mixin.pug")
.addTemplate("input-text.render.pug")
.and()
.batch(STYLE_SOURCE.append(ATOM_LABEL), STYLE_DESTINATION.append(ATOM_LABEL))
.addTemplate("_label.scss")
.addTemplate("label.code.pug")
.addTemplate("label.md")
.addTemplate("label.mixin.pug")
.addTemplate("label.render.pug")
.and()
.batch(STYLE_SOURCE.append(MOLECULE), STYLE_DESTINATION.append(MOLECULE))
.addTemplate("_molecule.scss")
.addTemplate("molecule.pug")
.and()
.batch(STYLE_SOURCE.append(MOLECULE_FIELD), STYLE_DESTINATION.append(MOLECULE_FIELD))
.addTemplate("_field.scss")
.addTemplate("field.code.pug")
.addTemplate("field.md")
.addTemplate("field.mixin.pug")
.addTemplate("field.render.pug")
.and()
.batch(STYLE_SOURCE.append(ORGANISM), STYLE_DESTINATION.append(ORGANISM))
.addTemplate("_organism.scss")
.addTemplate("organism.pug")
.and()
.batch(STYLE_SOURCE.append(QUARK), STYLE_DESTINATION.append(QUARK))
.addTemplate("_placeholder.scss")
.addTemplate("_spacing.scss")
.and()
.batch(STYLE_SOURCE.append(ORGANISM_LINES), STYLE_DESTINATION.append(ORGANISM_LINES))
.addTemplate("_lines.scss")
.addTemplate("lines.code.pug")
.addTemplate("lines.md")
.addTemplate("lines.mixin.pug")
.addTemplate("lines.render.pug")
.and()
.add(STYLE_SOURCE.template("template/template.pug"), STYLE_DESTINATION.append("template/template.pug"))
.batch(STYLE_SOURCE.append("token"), STYLE_DESTINATION.append("token"))
.addTemplate("spacing/_spacings.scss")
.addTemplate("spacing/_vars.scss")
.addTemplate("_animations.scss")
.addTemplate("_color.scss")
.addTemplate("_font.scss")
.addTemplate("_gradient.scss")
.addTemplate("_radius.scss")
.addTemplate("_size.scss")
.addTemplate("_token.scss")
.and()
.and()
.optionalReplacements()
.in(path("vite.config.ts"))
.add(existingProxyReplacer(), proxyForStyle(properties))
.add(newProxyReplacer(), newProxyForStyle(properties))
.and()
.in(path("proxy.conf.json"))
.add(lineBeforeText("\"/api\":"), styleProxyConf(properties))
.and()
.in(path("src/main/webapp/index.html"))
.add(lineBeforeText("</head>"), tikuiLink(properties))
.and()
.and()
.gitIgnore()
.pattern(".tikui-cache")
.and()
.build();
//@formatter:on
}

private static RegexNeedleAfterReplacer newProxyReplacer() {
return new RegexNeedleAfterReplacer(ReplacementCondition.notContaining("proxy:"), Pattern.compile("port:\\s*9000,", Pattern.MULTILINE));
}

private static RegexNeedleAfterReplacer existingProxyReplacer() {
return new RegexNeedleAfterReplacer(
(contentBeforeReplacement, replacement) -> contentBeforeReplacement.contains("proxy:"),
Pattern.compile("proxy:\\s*\\{", Pattern.MULTILINE)
);
}

private String tikuiLink(JHipsterModuleProperties properties) {
return properties.indentation().times(2) + "<link rel=\"stylesheet\" href=\"/style/tikui.css\" />";
}

private static String newProxyForStyle(JHipsterModuleProperties properties) {
return new StringBuilder()
.append(properties.indentation().times(2))
.append("proxy: {")
.append(LINE_BREAK)
.append(proxyForStyle(properties))
.append(LINE_BREAK)
.append(properties.indentation().times(2))
.append("},")
.toString();
}

private static String proxyForStyle(JHipsterModuleProperties properties) {
return """
{S}{S}{S}'/style': {
{S}{S}{S}{S}ws: true,
{S}{S}{S}{S}changeOrigin: true,
{S}{S}{S}{S}rewrite: path => path.replace('/style', ''),
{S}{S}{S}{S}target: 'http://localhost:9005',
{S}{S}{S}},""".replace("{S}", properties.indentation().times(1));
}

private String styleProxyConf(JHipsterModuleProperties properties) {
return """
{S}"/style": {
{S}{S}"target": "http://localhost:9005",
{S}{S}"secure": false
{S}},
""".replace("{S}", properties.indentation().times(1));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package tech.jhipster.lite.generator.client.tikui.infrastructure.primary;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import tech.jhipster.lite.generator.client.tikui.application.TikuiApplicationService;
import tech.jhipster.lite.generator.slug.domain.JHLiteFeatureSlug;
import tech.jhipster.lite.generator.slug.domain.JHLiteModuleSlug;
import tech.jhipster.lite.module.domain.resource.JHipsterModuleOrganization;
import tech.jhipster.lite.module.domain.resource.JHipsterModuleResource;

@Configuration
class TikuiModuleConfiguration {

@Bean
JHipsterModuleResource tikuiModule(TikuiApplicationService tikui) {
return JHipsterModuleResource.builder()
.slug(JHLiteModuleSlug.TIKUI)
.withoutProperties()
.apiDoc("Frontend", "Add Tikui, a pattern library to build your styles")
.organization(JHipsterModuleOrganization.builder().addDependency(JHLiteFeatureSlug.CLIENT_CORE).build())
.tags("client", "frontend", "tikui")
.factory(tikui::buildModule);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@tech.jhipster.lite.BusinessContext
package tech.jhipster.lite.generator.client.tikui;
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public enum JHLiteModuleSlug implements JHipsterModuleSlugFactory {
SPRINGDOC_OAUTH_2_AUTH_0("springdoc-oauth2-auth0"),
SPRINGDOC_OAUTH_2_OKTA("springdoc-oauth2-okta"),
SPRINGDOC_WEBFLUX_OPENAPI("springdoc-webflux-openapi"),
TIKUI("tikui"),
TS_LOADER("ts-loader"),
WEBJARS_LOCATOR("webjars-locator"),
HTMX_WEBJARS("htmx-webjars"),
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ application:
jhlite-hidden-resources:
slugs:
- svelte-core
- tikui

jhlite-preset-file:
name: preset.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"plugins": ["stylelint-scss", "stylelint-order"],
"extends": ["stylelint-config-standard-scss", "stylelint-config-concentric-order"],
"rules": {
"max-nesting-depth": 3,
"selector-class-pattern": "^-?([a-z][a-z0-9]*)(-[a-z0-9]+)*$",
"no-descending-specificity": null,
"selector-no-qualifying-type": [
true,
{
"ignore": ["class"]
}
],
"order/order": [
{
"type": "at-rule",
"name": "import"
},
"dollar-variables",
"custom-properties",
{
"type": "at-rule",
"name": "extend"
},
{
"type": "at-rule",
"name": "mixin"
},
{
"type": "at-rule",
"name": "add-mixin"
},
{
"type": "at-rule",
"name": "apply"
},
"declarations",
{
"type": "rule",
"selector": "/^&:[\\w-]+/",
"hasBlock": true
},
{
"type": "rule",
"selector": "/^&:[\\w-]+/",
"hasBlock": true
},
"rules",
{
"type": "at-rule",
"name": "include",
"parameter": "/breakpoints?/i",
"hasBlock": true
},
{
"type": "at-rule",
"name": "mixin",
"parameter": "/breakpoints?/i",
"hasBlock": true
},
{
"type": "at-rule",
"name": "add-mixin",
"parameter": "/breakpoints?/i",
"hasBlock": true
},
{
"type": "at-rule",
"name": "media",
"hasBlock": true
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@use 'button/button';
@use 'input-text/input-text';
@use 'label/label';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
extends /layout-documentation

block append vars
-active='atom'

block title
title Tikui - Atoms

block content
.tikui-vertical-spacing.-s32
.tikui-vertical-spacing--line
h1.tikui-title-main#atoms Atoms
.tikui-vertical-spacing--line
include /documentation/atomic-design/quote/atom
.tikui-vertical-spacing--line
include:componentDoc(height=80) button/button.md
.tikui-vertical-spacing--line
include:componentDoc(height=180) input-text/input-text.md
.tikui-vertical-spacing--line
include:componentDoc(height=70) label/label.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
@use '../../quark/placeholder';

.button {
--button-background: var(--color-primary);

box-sizing: border-box;
border: 1px solid var(--button-background);
border-radius: var(--radius-field);
background-color: var(--button-background);
cursor: pointer;
padding: var(--spacing-v-field) var(--spacing-h-field);
min-height: var(--height-field);
vertical-align: middle;
line-height: 1.25rem;
color: var(--color-text-on-primary);
font-size: 1rem;

&:hover {
--button-background: var(--color-primary-lighter);
}

&:disabled {
--button-background: var(--color-disabled);

cursor: not-allowed;
}

@include placeholder.placeholder-alternative {
cursor: default;
min-width: 6rem;
}
}
Loading