Skip to content

Commit

Permalink
Init tikui module
Browse files Browse the repository at this point in the history
  • Loading branch information
DamnClin committed Sep 21, 2024
1 parent 0178987 commit 4aeb489
Show file tree
Hide file tree
Showing 60 changed files with 853 additions and 1 deletion.
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,145 @@
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 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;

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(lineAfterRegex("port:\\s*9000,"), vueStyleProxy(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 String tikuiLink(JHipsterModuleProperties properties) {
return properties.indentation().times(2) + "<link rel=\"stylesheet\" href=\"/style/tikui.css\" />";
}

private static String vueStyleProxy(JHipsterModuleProperties properties) {
return """
{S}{S}proxy: {
{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}},
{S}{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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include button.mixin.pug

+button Button
+button Button #[br] multiple lines
+button({disabled: true}) Disabled
+button({placeholder: true})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Button
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mixin button(options)
-const { disabled, type, placeholder } = options || {};
-const placeholderClass = placeholder ? '-placeholder' : null;
button.button(disabled=disabled type=type class=placeholderClass)
block
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends /layout

block body
include button.code.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@use '../../quark/placeholder';

.input-text {
--input-text-border-color: var(--color-border-field);
box-sizing: border-box;
outline: none;
border: 1px solid var(--input-text-border-color);
border-radius: var(--radius-field);
background-color: var(--color-background);
padding: var(--spacing-v-field) var(--spacing-h-field);
width: 100%;
height: var(--height-field);
color: var(--color-text);
font-size: 1rem;
&:focus {
--input-text-border-color: var(--color-primary);
}

@include placeholder.placeholder-alternative {
cursor: default;
pointer-events: none;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include input-text.mixin.pug

+input-text
+input-text({placeholder: 'Placeholder'})
+input-text({value: 'Value', placeholder: 'Placeholder'})
+input-text({placeholderLoading: true})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Input text
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mixin input-text(options)
-const {id, placeholder, value, placeholderLoading} = options || {};
-const placeholderClass = placeholderLoading ? '-placeholder' : null;
input.input-text(id=id type='text' placeholder=placeholder class=placeholderClass)
Loading

0 comments on commit 4aeb489

Please sign in to comment.