ds-one 0.2.5-alpha.11 → 0.2.5-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,6 +104,10 @@ export function initDeviceDetection(): DeviceInfo {
104
104
  scalingFactor.toFixed(3)
105
105
  );
106
106
 
107
+ // Add .mobile class to html element for CSS targeting
108
+ document.documentElement.classList.add("mobile");
109
+ document.documentElement.classList.remove("desktop");
110
+
107
111
  console.log(
108
112
  `[DS one] Mobile device detected - ${deviceInfo.deviceType} (${deviceInfo.screenWidth}x${deviceInfo.screenHeight}), scaling factor: ${scalingFactor.toFixed(2)}`
109
113
  );
@@ -113,6 +117,10 @@ export function initDeviceDetection(): DeviceInfo {
113
117
  document.documentElement.style.setProperty("--sf", "1");
114
118
  // Also set --sf for backwards compatibility
115
119
  document.documentElement.style.setProperty("--sf", "1");
120
+
121
+ // Add .desktop class and remove .mobile class
122
+ document.documentElement.classList.add("desktop");
123
+ document.documentElement.classList.remove("mobile");
116
124
  }
117
125
  console.log(
118
126
  `[DS one] Desktop device detected (${deviceInfo.screenWidth}x${deviceInfo.screenHeight})`
@@ -1,4 +1,4 @@
1
- /* version 0.2.5-alpha.11 */
1
+ /* version 0.2.5-alpha.13 */
2
2
 
3
3
  @import url("https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@200");
4
4
 
@@ -54,9 +54,14 @@ input {
54
54
  --typeface-regular: "GT-America-Standard-Regular";
55
55
  --typeface-medium: "GT-America-Standard-Medium";
56
56
  --typeface-compressed: "GT-America-Compressed-Regular";
57
- --typeface-regular-jp: "Noto Sans JP";
58
57
  --typeface-mono: "Iosevka";
59
58
 
59
+ /* language specific typefaces */
60
+
61
+ --typeface-regular-jp: "Noto Sans JP";
62
+
63
+ /* typefaces sizes and weight */
64
+
60
65
  --type-size-default: calc(14px * var(--sf));
61
66
  --type-size-small: calc(10px * var(--sf));
62
67
  --type-weight-default: 500;
@@ -73,6 +78,35 @@ input {
73
78
  --type-weight-book: 400;
74
79
  --type-lineheight-book: 15px;
75
80
 
81
+ /* ----------------------------------------------------------
82
+ SIZING SCALE
83
+ - Define a base unit ( --1 ) and derive all other sizes
84
+ - Larger sizes are simple multipliers (×2, ×3, ×4)
85
+ - Smaller sizes use fractional multipliers (0.1, 0.25, 0.8)
86
+ ---------------------------------------------------------- */
87
+
88
+ --01: calc(var(--1) * 0.1);
89
+ --025: calc(var(--1) * 0.25);
90
+ --05: calc(var(--1) * 0.5);
91
+ --08: calc(var(--1) * 0.8);
92
+ --1: 20px; /* SET BASE UNIT HERE FOR EXAMPLE 20px */
93
+ --2: calc(var(--1) * 2);
94
+ --3: calc(var(--1) * 3);
95
+ --4: calc(var(--1) * 4);
96
+ --8: calc(var(--1) * 8);
97
+
98
+ /* Semantic sizing units */
99
+
100
+ --tenth: var(--01);
101
+ --quarter: var(--025);
102
+ --half: var(--05);
103
+ --eight-tenth: var(--08);
104
+ --unit: var(--1);
105
+ --double: var(--2);
106
+ --triple: var(--3);
107
+ --quad: var(--4);
108
+ --oct: var(--8);
109
+
76
110
  /* size */
77
111
  --outline-stroke: 1px solid light-dark(var(--black), var(--slate-dark));
78
112
  --outline-stroke-mobile: calc(1px * var(--sf)) solid
@@ -81,20 +115,6 @@ input {
81
115
  --item-height: calc(19px * var(--sf));
82
116
  --margin-correction: calc(1px * var(--sf));
83
117
 
84
- /* SIZING */
85
-
86
- /* main unit */
87
- --1: 20px;
88
- /* bigger sizes */
89
- --2: calc(var(--1) * 2);
90
- --3: calc(var(--1) * 3);
91
- --4: calc(var(--1) * 4);
92
-
93
- /* smaller sizes */
94
- --01: calc(var(--1) * 0.1);
95
- --025: calc(var(--1) * 0.25);
96
- --08: calc(var(--1) * 0.8);
97
-
98
118
  /* button */
99
119
  --button-background-color-primary: var(--accent-color);
100
120
  --button-background-color-secondary: light-dark(
@@ -1,8 +1,8 @@
1
1
  // ds-button.ts
2
2
  // Core button component
3
3
 
4
- import { LitElement, html, css, type PropertyValues } from "lit";
5
- import { getText, currentLanguage } from "../0-face/i18n";
4
+ import { LitElement, html, css } from "lit";
5
+ import "./ds-text";
6
6
 
7
7
  export class Button extends LitElement {
8
8
  static properties = {
@@ -21,7 +21,6 @@ export class Button extends LitElement {
21
21
  defaultText: { type: String, attribute: "default-text" },
22
22
  href: { type: String },
23
23
  _loading: { type: Boolean, state: true },
24
- _text: { type: String, state: true },
25
24
  };
26
25
 
27
26
  // Public properties
@@ -38,7 +37,6 @@ export class Button extends LitElement {
38
37
 
39
38
  // Private state
40
39
  declare _loading: boolean;
41
- declare _text: string | null;
42
40
 
43
41
  constructor() {
44
42
  super();
@@ -53,7 +51,6 @@ export class Button extends LitElement {
53
51
  this.defaultText = "";
54
52
  this.href = "";
55
53
  this._loading = false;
56
- this._text = null;
57
54
  }
58
55
 
59
56
  static styles = css`
@@ -61,8 +58,7 @@ export class Button extends LitElement {
61
58
  max-height: calc(var(--08) * var(--sf));
62
59
  border: none;
63
60
  cursor: pointer;
64
- font-size: calc(var(--type-size-default) * var(--sf));
65
- padding: 0 calc(1px * var(--sf));
61
+ padding: 0 calc(2px * var(--sf));
66
62
  color: var(--button-text-color);
67
63
  font-family: var(--typeface-regular);
68
64
  }
@@ -110,42 +106,11 @@ export class Button extends LitElement {
110
106
 
111
107
  connectedCallback() {
112
108
  super.connectedCallback();
113
- this._updateText();
114
-
115
- // Listen for language changes
116
- window.addEventListener("language-changed", this._handleLanguageChange);
117
- }
118
-
119
- disconnectedCallback() {
120
- super.disconnectedCallback();
121
- window.removeEventListener("language-changed", this._handleLanguageChange);
122
- }
123
-
124
- _handleLanguageChange = () => {
125
- this._updateText();
126
- };
127
-
128
- updated(changedProps: PropertyValues) {
129
- super.updated(changedProps);
130
-
131
- if (changedProps.has("key") || changedProps.has("defaultText")) {
132
- this._updateText();
133
- }
134
- }
135
-
136
- /**
137
- * Update text from translations (synchronous like Portfolio)
138
- */
139
- private _updateText() {
140
- if (this.key) {
141
- this._text = getText(this.key);
142
- } else {
143
- this._text = this.defaultText || this.fallback || null;
144
- }
145
- this.requestUpdate();
146
109
  }
147
110
 
148
111
  render() {
112
+ const hasTextProps = this.key || this.defaultText || this.fallback;
113
+
149
114
  return html`
150
115
  <button
151
116
  class=${this.variant}
@@ -154,7 +119,13 @@ export class Button extends LitElement {
154
119
  ?no-background=${this["no-background"]}
155
120
  @click=${this._handleClick}
156
121
  >
157
- ${this._text ? this._text : html`<slot></slot>`}
122
+ ${hasTextProps
123
+ ? html`<ds-text
124
+ .key=${this.key}
125
+ .defaultValue=${this.defaultText}
126
+ .fallback=${this.fallback}
127
+ ></ds-text>`
128
+ : html`<slot></slot>`}
158
129
  </button>
159
130
  `;
160
131
  }
@@ -690,24 +690,30 @@ export class Cycle extends LitElement {
690
690
  style="display: inline-flex; align-items: center; gap: var(--025)"
691
691
  >${this.getValueDisplay(this.currentValue)}</span
692
692
  >`
693
- : this.type === "theme"
693
+ : this.type === "language"
694
694
  ? html`<ds-text
695
- key=${this.currentValue}
696
- default-value=${this.currentValue}
695
+ default-value=${this.getValueDisplay(this.currentValue)}
697
696
  ></ds-text>`
698
- : this.type === "accent-color"
697
+ : this.type === "theme"
699
698
  ? html`<ds-text
700
- key=${this.getColorKey(this.currentValue)}
701
- default-value=${this.getColorName(this.currentValue)}
699
+ key=${this.currentValue}
700
+ default-value=${this.currentValue}
702
701
  ></ds-text>`
703
- : this.type === "page-style"
702
+ : this.type === "accent-color"
704
703
  ? html`<ds-text
705
- key=${this.currentValue}
706
- default-value=${this.currentValue}
704
+ key=${this.getColorKey(this.currentValue)}
705
+ default-value=${this.getColorName(this.currentValue)}
707
706
  ></ds-text>`
708
- : html`<ds-text
709
- default-value=${this.getValueDisplay(this.currentValue)}
710
- ></ds-text>`}
707
+ : this.type === "page-style"
708
+ ? html`<ds-text
709
+ key=${this.currentValue}
710
+ default-value=${this.currentValue}
711
+ ></ds-text>`
712
+ : html`<ds-text
713
+ default-value=${this.getValueDisplay(
714
+ this.currentValue
715
+ )}
716
+ ></ds-text>`}
711
717
  </ds-button>
712
718
  ${this.type === "accent-color"
713
719
  ? html`
@@ -39,6 +39,7 @@ export class Text extends LitElement {
39
39
  languageChanged: (() => {
40
40
  console.log("Language changed event received in ds-text");
41
41
  this._currentLanguage = currentLanguage.value;
42
+ this._updateLanguageAttribute();
42
43
  this._loadText();
43
44
  this.requestUpdate();
44
45
  }) as EventListener,
@@ -49,7 +50,7 @@ export class Text extends LitElement {
49
50
  :host {
50
51
  display: inline;
51
52
  font-family: var(--typeface-regular);
52
- font-size: calc(var(--type-size-default) * var(--sf));
53
+ font-size: var(--type-size-default);
53
54
  font-weight: var(--type-weight-default);
54
55
  line-height: calc(var(--type-lineheight-default) * var(--sf));
55
56
  letter-spacing: calc(var(--type-letterspacing-default) * var(--sf));
@@ -107,7 +108,9 @@ export class Text extends LitElement {
107
108
 
108
109
  _updateLanguageAttribute() {
109
110
  const lang = this._currentLanguage || currentLanguage.value;
110
- if (lang === "ja") {
111
+ // Check if language is Japanese (handles "ja", "ja-JP", etc.)
112
+ const primaryLang = lang?.toLowerCase().split(/[-_]/)[0] || "";
113
+ if (primaryLang === "ja") {
111
114
  this.setAttribute("data-language", "ja");
112
115
  } else {
113
116
  this.removeAttribute("data-language");
@@ -117,6 +120,8 @@ export class Text extends LitElement {
117
120
  _loadText() {
118
121
  if (!this.key) {
119
122
  this._text = this.defaultValue || this.fallback || "";
123
+ this._updateLanguageAttribute();
124
+ this.requestUpdate();
120
125
  return;
121
126
  }
122
127
 
@@ -0,0 +1,59 @@
1
+ // ds-container.ts
2
+ // Container component with responsive width constraints
3
+
4
+ import { LitElement, html, css } from "lit";
5
+
6
+ declare global {
7
+ interface CustomElementRegistry {
8
+ define(name: string, constructor: typeof LitElement): void;
9
+ }
10
+ var customElements: CustomElementRegistry;
11
+ }
12
+
13
+ export class Container extends LitElement {
14
+ static styles = css`
15
+ :host {
16
+ display: flex;
17
+ width: 100%;
18
+ max-width: 100%;
19
+ flex-direction: column;
20
+ box-sizing: border-box;
21
+ }
22
+
23
+ /* Ensure children don't overflow */
24
+ :host ::slotted(*) {
25
+ max-width: 100%;
26
+ box-sizing: border-box;
27
+ }
28
+
29
+ /* Mobile: 100% width */
30
+ @media (max-width: 820px) {
31
+ :host {
32
+ width: 100%;
33
+ max-width: 100%;
34
+ }
35
+ }
36
+
37
+ /* Desktop: max-width 1000px, centered */
38
+ @media (min-width: 821px) {
39
+ :host {
40
+ max-width: 1000px;
41
+ margin-left: auto;
42
+ margin-right: auto;
43
+ width: 100%;
44
+ }
45
+ }
46
+ `;
47
+
48
+ render() {
49
+ return html`<slot></slot>`;
50
+ }
51
+ }
52
+
53
+ customElements.define("ds-container", Container);
54
+
55
+ declare global {
56
+ interface HTMLElementTagNameMap {
57
+ "ds-container": Container;
58
+ }
59
+ }
@@ -2,6 +2,7 @@
2
2
  // Simple grid layout component
3
3
 
4
4
  import { LitElement, html, css } from "lit";
5
+ import { detectMobileDevice } from "../0-face/device";
5
6
 
6
7
  declare global {
7
8
  interface CustomElementRegistry {
@@ -16,6 +17,8 @@ export class Grid extends LitElement {
16
17
  };
17
18
 
18
19
  align?: string;
20
+ private resizeObserver?: () => void;
21
+ private resizeTimeout?: any;
19
22
 
20
23
  static styles = css`
21
24
  :host {
@@ -23,13 +26,13 @@ export class Grid extends LitElement {
23
26
  margin-left: 0.5px !important;
24
27
  display: grid;
25
28
  width: 1440px;
26
- height: 360px;
29
+ height: 1280px;
27
30
  grid-template-columns: repeat(auto-fill, 19px);
28
31
  grid-template-rows: repeat(auto-fill, 19px);
29
32
  gap: 1px;
30
33
  row-rule: calc(1px * var(--sf)) solid var(--grid-color);
31
34
  column-rule: calc(1px * var(--sf)) solid var(--grid-color);
32
- outline: 1px solid black;
35
+ outline: calc(1px * var(--sf)) solid var(--yellow);
33
36
  position: fixed;
34
37
  top: 0;
35
38
  left: 50%;
@@ -42,7 +45,7 @@ export class Grid extends LitElement {
42
45
  :host(.mobile) {
43
46
  width: calc(100% - calc(1px * var(--sf)));
44
47
  max-width: 100vw;
45
- margin-left: 0 !important;
48
+ margin-left: 0.5px !important;
46
49
  margin-top: 0 !important;
47
50
  box-sizing: border-box;
48
51
  position: fixed;
@@ -73,6 +76,43 @@ export class Grid extends LitElement {
73
76
  }
74
77
  `;
75
78
 
79
+ connectedCallback() {
80
+ super.connectedCallback();
81
+ this.updateMobileClass();
82
+
83
+ // Listen for resize events to update mobile class
84
+ this.resizeObserver = () => {
85
+ if (this.resizeTimeout) {
86
+ clearTimeout(this.resizeTimeout);
87
+ }
88
+ this.resizeTimeout = setTimeout(() => {
89
+ this.updateMobileClass();
90
+ }, 100);
91
+ };
92
+ window.addEventListener("resize", this.resizeObserver);
93
+ }
94
+
95
+ disconnectedCallback() {
96
+ super.disconnectedCallback();
97
+ if (this.resizeObserver) {
98
+ window.removeEventListener("resize", this.resizeObserver);
99
+ }
100
+ if (this.resizeTimeout) {
101
+ clearTimeout(this.resizeTimeout);
102
+ }
103
+ }
104
+
105
+ private updateMobileClass() {
106
+ const isMobile = detectMobileDevice();
107
+ if (isMobile) {
108
+ this.classList.add("mobile");
109
+ this.classList.remove("desktop");
110
+ } else {
111
+ this.classList.add("desktop");
112
+ this.classList.remove("mobile");
113
+ }
114
+ }
115
+
76
116
  render() {
77
117
  return html``;
78
118
  }