ds-one 0.1.11-alpha.1 → 0.1.11-alpha.11

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.
Files changed (38) hide show
  1. package/DS1/0-face/2025-04-23-device.ts +135 -1
  2. package/DS1/1-root/fonts/GT-America-Compressed-Regular.woff2 +0 -0
  3. package/DS1/1-root/one.css +16 -2
  4. package/DS1/2-core/{text-v1.ts → ds-text.ts} +4 -4
  5. package/DS1/2-core/home-v1.ts +2 -2
  6. package/DS1/3-unit/doublenav-v1.ts +2 -2
  7. package/DS1/3-unit/singlenav-v1.ts +1 -1
  8. package/DS1/4-page/ds-grid.ts +74 -9
  9. package/DS1/4-page/ds-layout.ts +1 -20
  10. package/DS1/index.ts +7 -1
  11. package/DS1/utils/cdn-loader.ts +5 -0
  12. package/DS1/utils/keys.json +41 -1
  13. package/README.md +5 -5
  14. package/dist/0-face/2025-04-23-device.d.ts +24 -0
  15. package/dist/0-face/2025-04-23-device.d.ts.map +1 -1
  16. package/dist/0-face/2025-04-23-device.js +94 -1
  17. package/dist/2-core/ds-text.d.ts +48 -0
  18. package/dist/2-core/ds-text.d.ts.map +1 -0
  19. package/dist/2-core/ds-text.js +83 -0
  20. package/dist/2-core/home-v1.js +2 -2
  21. package/dist/3-unit/doublenav-v1.js +2 -2
  22. package/dist/3-unit/singlenav-v1.js +1 -1
  23. package/dist/4-page/ds-grid.d.ts +7 -0
  24. package/dist/4-page/ds-grid.d.ts.map +1 -1
  25. package/dist/4-page/ds-grid.js +69 -9
  26. package/dist/4-page/ds-layout.d.ts.map +1 -1
  27. package/dist/4-page/ds-layout.js +1 -20
  28. package/dist/ds-one.bundle.js +190 -39
  29. package/dist/ds-one.bundle.js.map +3 -3
  30. package/dist/ds-one.bundle.min.js +68 -67
  31. package/dist/ds-one.bundle.min.js.map +4 -4
  32. package/dist/index.d.ts +3 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +5 -1
  35. package/dist/utils/cdn-loader.d.ts.map +1 -1
  36. package/dist/utils/cdn-loader.js +5 -0
  37. package/dist/utils/keys.json +41 -1
  38. package/package.json +1 -1
@@ -1,3 +1,74 @@
1
+ // dist/0-face/2025-04-23-device.js
2
+ function detectMobileDevice() {
3
+ if (typeof navigator === "undefined" || typeof window === "undefined") {
4
+ return false;
5
+ }
6
+ const nav = navigator;
7
+ const win = window;
8
+ const ua = nav && (nav.userAgent || nav.vendor) || win && win.opera || "";
9
+ const uaMatchesMobile = /Mobile|Android|iP(ad|hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)|Windows Phone|Phone|Tablet/i.test(ua);
10
+ const touchPoints = nav && nav.maxTouchPoints || 0;
11
+ const isTouchCapable = touchPoints > 1;
12
+ const narrowViewport = win ? Math.min(win.innerWidth || 0, win.innerHeight || 0) <= 820 : false;
13
+ return uaMatchesMobile || isTouchCapable && narrowViewport;
14
+ }
15
+ function getDeviceInfo() {
16
+ const isMobile = detectMobileDevice();
17
+ const nav = navigator;
18
+ const win = window;
19
+ const touchPoints = nav && nav.maxTouchPoints || 0;
20
+ const isTouchCapable = touchPoints > 1;
21
+ const screenWidth = win?.innerWidth || 0;
22
+ const screenHeight = win?.innerHeight || 0;
23
+ const isTablet = isMobile && Math.min(screenWidth, screenHeight) >= 600;
24
+ return {
25
+ isMobile,
26
+ isTablet,
27
+ isDesktop: !isMobile,
28
+ isTouchCapable,
29
+ deviceType: isMobile ? isTablet ? "tablet" : "mobile" : "desktop",
30
+ userAgent: nav && (nav.userAgent || nav.vendor) || "",
31
+ screenWidth,
32
+ screenHeight
33
+ };
34
+ }
35
+ function initDeviceDetection() {
36
+ const deviceInfo = getDeviceInfo();
37
+ if (deviceInfo.isMobile && typeof document !== "undefined") {
38
+ const designWidth = 280;
39
+ const actualWidth = deviceInfo.screenWidth;
40
+ const scalingFactor = actualWidth / designWidth;
41
+ document.documentElement.style.setProperty("--scaling-factor-mobile", scalingFactor.toFixed(3));
42
+ console.log(`[DS one] Mobile device detected - ${deviceInfo.deviceType} (${deviceInfo.screenWidth}x${deviceInfo.screenHeight}), scaling factor: ${scalingFactor.toFixed(2)}`);
43
+ } else {
44
+ if (typeof document !== "undefined") {
45
+ document.documentElement.style.setProperty("--scaling-factor-mobile", "1");
46
+ }
47
+ console.log(`[DS one] Desktop device detected (${deviceInfo.screenWidth}x${deviceInfo.screenHeight})`);
48
+ }
49
+ if (typeof window !== "undefined" && window.DS_ONE_DEBUG) {
50
+ console.log("[DS one] Device Info:", {
51
+ type: deviceInfo.deviceType,
52
+ isMobile: deviceInfo.isMobile,
53
+ isTablet: deviceInfo.isTablet,
54
+ isDesktop: deviceInfo.isDesktop,
55
+ isTouchCapable: deviceInfo.isTouchCapable,
56
+ viewport: `${deviceInfo.screenWidth}x${deviceInfo.screenHeight}`,
57
+ userAgent: deviceInfo.userAgent
58
+ });
59
+ }
60
+ return deviceInfo;
61
+ }
62
+ if (typeof window !== "undefined") {
63
+ if (document.readyState === "loading") {
64
+ document.addEventListener("DOMContentLoaded", () => {
65
+ initDeviceDetection();
66
+ });
67
+ } else {
68
+ initDeviceDetection();
69
+ }
70
+ }
71
+
1
72
  // dist/utils/cdn-loader.js
2
73
  var loadAttempted = false;
3
74
  var DEFAULT_TRANSLATION_FILES = [
@@ -69,11 +140,14 @@ function validateTranslationMap(candidate) {
69
140
  }
70
141
  async function fetchTranslationFile(source) {
71
142
  try {
143
+ console.log(`[DS one] Attempting to fetch translations from: ${source}`);
72
144
  const response = await fetch(source);
73
145
  if (!response.ok) {
146
+ console.log(`[DS one] Failed to fetch ${source} (${response.status})`);
74
147
  return null;
75
148
  }
76
149
  const translations = await response.json();
150
+ console.log(`[DS one] Successfully fetched JSON from ${source}`);
77
151
  if (!validateTranslationMap(translations)) {
78
152
  console.warn(`[DS one] Invalid translation format in ${source}. Expected object with language codes as keys.`);
79
153
  return null;
@@ -83,9 +157,11 @@ async function fetchTranslationFile(source) {
83
157
  console.warn(`[DS one] No languages found in ${source}`);
84
158
  return null;
85
159
  }
160
+ console.log(`[DS one] Valid translations found: ${languages.join(", ")}`);
86
161
  return translations;
87
162
  } catch (error) {
88
163
  if (error instanceof TypeError && error.message.includes("Failed to fetch")) {
164
+ console.log(`[DS one] Network error fetching ${source}`);
89
165
  return null;
90
166
  }
91
167
  console.error(`[DS one] Error loading external translations from ${source}:`, error);
@@ -681,7 +757,47 @@ o4?.({ LitElement: i4 });
681
757
  (s3.litElementVersions ?? (s3.litElementVersions = [])).push("4.2.1");
682
758
 
683
759
  // dist/utils/keys.json
684
- var keys_default = {};
760
+ var keys_default = {
761
+ en: {
762
+ language: "Language",
763
+ theme: "Theme",
764
+ home: "Home",
765
+ about: "About",
766
+ contact: "Contact",
767
+ welcome: "Welcome",
768
+ description: "Description",
769
+ learnMore: "Learn More",
770
+ copyright: "\xA9 2025",
771
+ siteTitle: "Site Title",
772
+ downloadCV: "Download CV"
773
+ },
774
+ da: {
775
+ language: "Sprog",
776
+ theme: "Tema",
777
+ home: "Hjem",
778
+ about: "Om",
779
+ contact: "Kontakt",
780
+ welcome: "Velkommen",
781
+ description: "Beskrivelse",
782
+ learnMore: "L\xE6r Mere",
783
+ copyright: "\xA9 2025",
784
+ siteTitle: "Site Titel",
785
+ downloadCV: "Download CV"
786
+ },
787
+ ja: {
788
+ language: "\u8A00\u8A9E",
789
+ theme: "\u30C6\u30FC\u30DE",
790
+ home: "\u30DB\u30FC\u30E0",
791
+ about: "\u306B\u3064\u3044\u3066",
792
+ contact: "\u304A\u554F\u3044\u5408\u308F\u305B",
793
+ welcome: "\u3088\u3046\u3053\u305D",
794
+ description: "\u8AAC\u660E",
795
+ learnMore: "\u8A73\u7D30\u3092\u898B\u308B",
796
+ copyright: "\xA9 2025",
797
+ siteTitle: "\u30B5\u30A4\u30C8\u30BF\u30A4\u30C8\u30EB",
798
+ downloadCV: "CV\u3092\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9"
799
+ }
800
+ };
685
801
 
686
802
  // dist/utils/language.js
687
803
  var LANGUAGE_PRIORITY_ORDER = [
@@ -1169,7 +1285,7 @@ Button.styles = i`
1169
1285
  `;
1170
1286
  customElements.define("ds-button", Button);
1171
1287
 
1172
- // dist/2-core/text-v1.js
1288
+ // dist/2-core/ds-text.js
1173
1289
  var Text = class extends i4 {
1174
1290
  static get properties() {
1175
1291
  return {
@@ -1188,7 +1304,7 @@ var Text = class extends i4 {
1188
1304
  this._text = "";
1189
1305
  this.boundHandlers = {
1190
1306
  languageChanged: (() => {
1191
- console.log("Language changed event received in text-v1");
1307
+ console.log("Language changed event received in ds-text");
1192
1308
  this._loadText();
1193
1309
  })
1194
1310
  };
@@ -1237,7 +1353,7 @@ Text.styles = i`
1237
1353
  opacity: 0.6;
1238
1354
  }
1239
1355
  `;
1240
- customElements.define("text-v1", Text);
1356
+ customElements.define("ds-text", Text);
1241
1357
 
1242
1358
  // node_modules/lit-html/directive.js
1243
1359
  var t3 = { ATTRIBUTE: 1, CHILD: 2, PROPERTY: 3, BOOLEAN_ATTRIBUTE: 4, EVENT: 5, ELEMENT: 6 };
@@ -3283,7 +3399,7 @@ var Home = class extends i4 {
3283
3399
  @click="${this._navigateHome}"
3284
3400
  @keydown="${this._onKeyDown}"
3285
3401
  >
3286
- <text-v1 key="home"></text-v1>
3402
+ <ds-text key="home"></ds-text>
3287
3403
  </div>
3288
3404
  `;
3289
3405
  }
@@ -3328,7 +3444,7 @@ Home.styles = i`
3328
3444
  }
3329
3445
 
3330
3446
  /* Inner text spacing without affecting the 80px outer width */
3331
- .home > text-v1 {
3447
+ .home > ds-text {
3332
3448
  padding: 0 calc(var(--1) * 0.15 * var(--scaling-factor));
3333
3449
  box-sizing: border-box;
3334
3450
  height: 100%;
@@ -4370,7 +4486,7 @@ var SingleNav = class extends i4 {
4370
4486
  const href = this.to || navConfig.href;
4371
4487
  return x`
4372
4488
  <a href="${href}">
4373
- <text-v1 key="${navConfig.key}"></text-v1>
4489
+ <ds-text key="${navConfig.key}"></ds-text>
4374
4490
  <icon-v1 type="right"></icon-v1>
4375
4491
  </a>
4376
4492
  `;
@@ -4433,12 +4549,12 @@ var DoubleNav = class extends i4 {
4433
4549
  ${this.previous ? x`
4434
4550
  <a href="${this.previous}" class="nav-previous">
4435
4551
  <icon-v1 type="left"></icon-v1>
4436
- <text-v1>${this.previousText || "Previous"}</text-v1>
4552
+ <ds-text>${this.previousText || "Previous"}</ds-text>
4437
4553
  </a>
4438
4554
  ` : x`<div></div>`}
4439
4555
  ${this.next ? x`
4440
4556
  <a href="${this.next}" class="nav-next">
4441
- <text-v1>${this.nextText || "Next"}</text-v1>
4557
+ <ds-text>${this.nextText || "Next"}</ds-text>
4442
4558
  <icon-v1 type="right"></icon-v1>
4443
4559
  </a>
4444
4560
  ` : x`<div></div>`}
@@ -4609,29 +4725,60 @@ customElements.define("ds-table", DsTable);
4609
4725
 
4610
4726
  // dist/4-page/ds-grid.js
4611
4727
  var Grid = class extends i4 {
4728
+ constructor() {
4729
+ super(...arguments);
4730
+ this._isMobile = false;
4731
+ }
4732
+ connectedCallback() {
4733
+ super.connectedCallback();
4734
+ this._isMobile = detectMobileDevice();
4735
+ console.log(`[ds-grid] Mobile device: ${this._isMobile}`);
4736
+ if (this._isMobile) {
4737
+ this.classList.add("mobile");
4738
+ console.log(`[ds-grid] Mobile class added`);
4739
+ }
4740
+ if (this._isMobile && typeof window !== "undefined") {
4741
+ const screenWidth = window.innerWidth;
4742
+ const columns = 14;
4743
+ const gap = 0.5;
4744
+ const totalGapWidth = (columns - 1) * gap;
4745
+ const columnSize = (screenWidth - totalGapWidth) / columns;
4746
+ console.log(`[ds-grid] Mobile grid: ${columns} columns \xD7 ${columnSize.toFixed(2)}px + ${totalGapWidth}px gaps = ${screenWidth}px`);
4747
+ this.style.setProperty("--mobile-column-size", `${columnSize}px`);
4748
+ this.style.setProperty("--mobile-gap", `${gap}px`);
4749
+ }
4750
+ }
4751
+ updated() {
4752
+ if (this._isMobile) {
4753
+ this.classList.add("mobile");
4754
+ } else {
4755
+ this.classList.remove("mobile");
4756
+ }
4757
+ }
4612
4758
  render() {
4613
4759
  return x``;
4614
4760
  }
4615
4761
  };
4616
4762
  Grid.properties = {
4617
- align: { type: String }
4763
+ align: { type: String },
4764
+ _isMobile: { type: Boolean, state: true }
4618
4765
  };
4619
4766
  Grid.styles = i`
4620
4767
  :host {
4621
4768
  margin-top: 0.5px !important;
4622
4769
  margin-left: 0.5px !important;
4623
4770
  display: grid;
4624
- width: 100%;
4771
+ width: 1440px;
4625
4772
  height: 100%;
4626
4773
  grid-template-columns: repeat(auto-fill, 19px);
4627
4774
  grid-template-rows: repeat(auto-fill, 19px);
4628
4775
  gap: 1px;
4629
- row-rule: 1px solid
4630
- light-dark(rgba(0, 0, 0, 0.03), rgba(215, 215, 215, 0.022));
4631
- column-rule: 1px solid
4632
- light-dark(rgba(0, 0, 0, 0.03), rgba(238, 238, 238, 0.022));
4633
- outline: 1px solid light-dark(rgba(0, 0, 0, 0.15), #100101e7);
4634
- position: absolute;
4776
+ row-rule: 1px solid light-dark(rgb(147, 147, 147), rgb(147, 147, 147));
4777
+ column-rule: 1px solid light-dark(rgb(147, 147, 147), rgb(147, 147, 147));
4778
+ outline:
4779
+ 1px solid light-dark(rgb(147, 147, 147)),
4780
+ rgb(147, 147, 147);
4781
+ position: fixed;
4635
4782
  top: 0;
4636
4783
  left: 50%;
4637
4784
  transform: translateX(-50%);
@@ -4639,6 +4786,25 @@ Grid.styles = i`
4639
4786
  z-index: 300;
4640
4787
  }
4641
4788
 
4789
+ /* DO NOT CHANGE THIS GRID CODE FOR MOBILE. ITS PERFECT FOR MOBILE. */
4790
+ :host(.mobile) {
4791
+ outline: calc(2px * var(--scaling-factor)) solid rgba(251, 255, 0, 0.9);
4792
+ width: calc(100% - calc(1px * var(--scaling-factor)));
4793
+ max-width: 100vw;
4794
+ margin-left: 0 !important;
4795
+ margin-top: 0 !important;
4796
+ box-sizing: border-box;
4797
+ position: fixed;
4798
+ top: calc(0.5px * var(--scaling-factor));
4799
+ left: 50%;
4800
+ transform: translateX(-50%);
4801
+ pointer-events: none;
4802
+ z-index: 300;
4803
+ gap: calc(1px * var(--scaling-factor));
4804
+ grid-template-columns: repeat(14, calc(19px * var(--scaling-factor)));
4805
+ grid-template-rows: repeat(auto-fill, calc(19px * var(--scaling-factor)));
4806
+ }
4807
+
4642
4808
  :host([align="left"]) {
4643
4809
  left: 0;
4644
4810
  transform: none;
@@ -4650,8 +4816,9 @@ Grid.styles = i`
4650
4816
  }
4651
4817
 
4652
4818
  :host([align="right"]) {
4653
- left: 100%;
4654
- transform: translateX(-100%);
4819
+ left: auto;
4820
+ right: 0;
4821
+ transform: none;
4655
4822
  }
4656
4823
  `;
4657
4824
  customElements.define("ds-grid", Grid);
@@ -4706,7 +4873,7 @@ Layout.styles = i`
4706
4873
  ". footer ."
4707
4874
  ". . .";
4708
4875
  min-height: 600px;
4709
- background-color: rgba(235, 231, 231, 0.44);
4876
+ background-color: rgba(165, 165, 165, 0.03);
4710
4877
  position: relative;
4711
4878
  width: 100%;
4712
4879
  max-width: 640px;
@@ -4742,10 +4909,6 @@ Layout.styles = i`
4742
4909
  justify-self: end;
4743
4910
  }
4744
4911
 
4745
- :host([mode="debug"]) {
4746
- background-color: rgba(200, 114, 114, 0.1);
4747
- }
4748
-
4749
4912
  .debug-overlay {
4750
4913
  position: absolute;
4751
4914
  margin-left: -1px;
@@ -4794,7 +4957,6 @@ Layout.styles = i`
4794
4957
  font-size: 10px;
4795
4958
  font-weight: var(--type-weight-default);
4796
4959
  font-family: var(--typeface);
4797
- background-color: var(--slate);
4798
4960
  color: var(--black);
4799
4961
  border: 1px solid red;
4800
4962
  opacity: 1;
@@ -4802,53 +4964,39 @@ Layout.styles = i`
4802
4964
 
4803
4965
  .debug-square {
4804
4966
  grid-area: square;
4805
- background-color: rgba(255, 0, 0, 0.2);
4806
4967
  }
4807
4968
 
4808
4969
  .debug-title {
4809
4970
  grid-area: title;
4810
- background-color: rgba(0, 255, 0, 0.2);
4811
4971
  }
4812
4972
 
4813
4973
  .debug-header {
4814
4974
  grid-area: header;
4815
- background-color: rgba(0, 0, 255, 0.2);
4816
4975
  border-color: #0000ff;
4817
4976
  }
4818
4977
 
4819
4978
  .debug-projects {
4820
4979
  grid-area: projects;
4821
- background-color: rgba(255, 255, 0, 0.2);
4822
4980
  border-color: #ffff00;
4823
4981
  }
4824
4982
 
4825
4983
  .debug-bio {
4826
4984
  grid-area: bio;
4827
- background-color: rgba(255, 0, 255, 0.2);
4828
4985
  border-color: #ff00ff;
4829
4986
  }
4830
4987
 
4831
4988
  .debug-nav {
4832
4989
  grid-area: nav;
4833
- background-color: rgba(0, 255, 255, 0.2);
4834
4990
  border-color: #00ffff;
4835
4991
  }
4836
4992
 
4837
4993
  .debug-footer {
4838
4994
  grid-area: footer;
4839
- background-color: rgba(255, 165, 0, 0.2);
4840
4995
  border-color: #ffa500;
4841
4996
  }
4842
4997
 
4843
- .debug-header {
4844
- grid-area: header;
4845
- background-color: rgba(0, 0, 255, 0.2);
4846
- border-color: #0000ff;
4847
- }
4848
-
4849
4998
  .debug-content {
4850
4999
  grid-area: content;
4851
- background-color: rgba(21, 169, 21, 0.57);
4852
5000
  border-color: rgba(71, 231, 71, 0.63);
4853
5001
  }
4854
5002
  `;
@@ -4987,9 +5135,11 @@ export {
4987
5135
  clearScrollPosition,
4988
5136
  currentLanguage,
4989
5137
  currentTheme,
5138
+ detectMobileDevice,
4990
5139
  getAvailableLanguages,
4991
5140
  getAvailableLanguagesSync,
4992
5141
  getBrowserLanguage,
5142
+ getDeviceInfo,
4993
5143
  getLanguageDisplayName,
4994
5144
  getNotionText,
4995
5145
  getPriceLabel,
@@ -4997,6 +5147,7 @@ export {
4997
5147
  getText,
4998
5148
  getViewMode,
4999
5149
  hasTranslation,
5150
+ initDeviceDetection,
5000
5151
  initScrollManagement,
5001
5152
  loadTranslations,
5002
5153
  restoreScrollPosition,