@rdlabo/ionic-theme-ios26 0.3.4 → 0.4.0

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 (64) hide show
  1. package/README.md +21 -10
  2. package/dist/css/components/ion-segment.css +1 -1
  3. package/dist/css/components/ion-tabs.css +1 -1
  4. package/dist/css/ionic-theme-ios26.css +1 -1
  5. package/dist/css/md-remove-ios-class-effect.css +1 -1
  6. package/dist/gestures/gestures.d.ts +3 -0
  7. package/dist/gestures/gestures.d.ts.map +1 -0
  8. package/dist/gestures/gestures.js +240 -0
  9. package/dist/gestures/index.d.ts +3 -0
  10. package/dist/gestures/index.d.ts.map +1 -0
  11. package/dist/gestures/index.js +240 -0
  12. package/dist/gestures/interfaces.d.ts +10 -0
  13. package/dist/gestures/interfaces.d.ts.map +1 -0
  14. package/dist/gestures/interfaces.js +1 -0
  15. package/dist/gestures/utils.d.ts +3 -0
  16. package/dist/gestures/utils.d.ts.map +1 -0
  17. package/dist/gestures/utils.js +24 -0
  18. package/dist/index.d.ts +4 -2
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +16 -206
  21. package/dist/utils.d.ts +3 -0
  22. package/dist/utils.d.ts.map +1 -0
  23. package/dist/utils.js +24 -0
  24. package/package.json +2 -2
  25. package/src/gestures/index.ts +290 -0
  26. package/src/gestures/interfaces.ts +10 -0
  27. package/src/gestures/utils.ts +28 -0
  28. package/src/index.ts +18 -241
  29. package/src/styles/components/ion-segment.scss +106 -0
  30. package/src/{components → styles/components}/ion-tabs.scss +2 -2
  31. package/src/{md-remove-ios-class-effect.scss → styles/md-remove-ios-class-effect.scss} +2 -2
  32. package/src/components/ion-segment.scss +0 -64
  33. /package/src/{components → styles/components}/ion-action-sheet.scss +0 -0
  34. /package/src/{components → styles/components}/ion-alert.scss +0 -0
  35. /package/src/{components → styles/components}/ion-breadcrumbs.scss +0 -0
  36. /package/src/{components → styles/components}/ion-button.scss +0 -0
  37. /package/src/{components → styles/components}/ion-card.scss +0 -0
  38. /package/src/{components → styles/components}/ion-chip.scss +0 -0
  39. /package/src/{components → styles/components}/ion-content.scss +0 -0
  40. /package/src/{components → styles/components}/ion-datetime.scss +0 -0
  41. /package/src/{components → styles/components}/ion-fab.scss +0 -0
  42. /package/src/{components → styles/components}/ion-list.scss +0 -0
  43. /package/src/{components → styles/components}/ion-loading.scss +0 -0
  44. /package/src/{components → styles/components}/ion-modal.scss +0 -0
  45. /package/src/{components → styles/components}/ion-picker.scss +0 -0
  46. /package/src/{components → styles/components}/ion-popover.scss +0 -0
  47. /package/src/{components → styles/components}/ion-range.scss +0 -0
  48. /package/src/{components → styles/components}/ion-searchbar.scss +0 -0
  49. /package/src/{components → styles/components}/ion-toast.scss +0 -0
  50. /package/src/{components → styles/components}/ion-toggle.scss +0 -0
  51. /package/src/{components → styles/components}/ion-toolbar.scss +0 -0
  52. /package/src/{default-variables.scss → styles/default-variables.scss} +0 -0
  53. /package/src/{ionic-theme-ios26-dark-always.scss → styles/ionic-theme-ios26-dark-always.scss} +0 -0
  54. /package/src/{ionic-theme-ios26-dark-class.scss → styles/ionic-theme-ios26-dark-class.scss} +0 -0
  55. /package/src/{ionic-theme-ios26-dark-system.scss → styles/ionic-theme-ios26-dark-system.scss} +0 -0
  56. /package/src/{ionic-theme-ios26.scss → styles/ionic-theme-ios26.scss} +0 -0
  57. /package/src/{md-ion-list-inset.scss → styles/md-ion-list-inset.scss} +0 -0
  58. /package/src/{utils → styles/utils}/api.scss +0 -0
  59. /package/src/{utils → styles/utils}/dark/ion-button.scss +0 -0
  60. /package/src/{utils → styles/utils}/dark/ion-fab.scss +0 -0
  61. /package/src/{utils → styles/utils}/dark/ion-tabs.scss +0 -0
  62. /package/src/{utils → styles/utils}/theme-dark.scss +0 -0
  63. /package/src/{utils → styles/utils}/theme-list-inset.scss +0 -0
  64. /package/src/{utils → styles/utils}/translucent.scss +0 -0
package/src/index.ts CHANGED
@@ -1,244 +1,21 @@
1
- import { createGesture, GestureDetail, createAnimation } from '@ionic/core';
2
- import type { Animation } from '@ionic/core/dist/types/utils/animation/animation-interface';
3
- import { Gesture } from '@ionic/core/dist/types/utils/gesture';
4
-
5
- export const registerTabBarEffect = (ionTabBar: HTMLElement): Gesture => {
6
- let gesture!: Gesture;
7
- let currentTouchedButton: HTMLIonTabButtonElement | null;
8
- let gestureMoveStartTime: number | null;
9
- let tabEffectElY: number | null;
10
-
11
- const tabEffectEl = cloneElement('ion-tab-button');
12
- const GestureName = 'tab-bar-gesture';
13
- const MinScale = 'scale(1.1)';
14
- const MiddleScale = 'scale(1.2)';
15
- const MaxScale = 'scale(1.3)';
16
- const OverScale = 'scale(1.4)';
17
-
18
- ionTabBar.addEventListener('pointerdown', () => clearActivated());
19
-
20
- const createTabButtonGesture = () => {
21
- ionTabBar.classList.add('tab-bar-ios26-effect');
22
- gesture = createGesture({
23
- el: ionTabBar,
24
- threshold: 0,
25
- gestureName: GestureName,
26
- onStart: (event) => {
27
- enterTabButtonAnimation(event)?.play();
28
- },
29
- onMove: (event) => {
30
- moveTabButtonAnimation(event)?.play();
31
- },
32
- onEnd: (event) => {
33
- leaveTabButtonAnimation(event).then((animation) => animation?.play());
34
- },
35
- });
36
- gesture.enable(true);
37
- };
38
- createTabButtonGesture();
39
-
40
- const clearActivated = (isAfterAddWrite = false) => {
41
- if (currentTouchedButton) {
42
- tabEffectEl.style.display = 'none';
43
- tabEffectEl.innerHTML = '';
44
- tabEffectEl.style.top = 'auto';
45
- tabEffectEl.style.top = 'left';
46
- tabEffectEl.style.transform = 'none';
47
-
48
- currentTouchedButton!.classList.remove('ion-activated');
49
- if (isAfterAddWrite) {
50
- currentTouchedButton.click();
51
- }
52
-
53
- /**
54
- * もしこの処理がafterAddWrite以外で走る場合、正常に終了していない
55
- */
56
- if (!isAfterAddWrite) {
57
- gesture.destroy();
58
- createTabButtonGesture();
59
- }
60
- currentTouchedButton = null;
61
- }
62
- };
63
-
64
- const getTransform = (detailCurrentX: number, tabSelectedActual: Element): string => {
65
- const diff = -2;
66
- const currentX = detailCurrentX - tabSelectedActual.clientWidth / 2;
67
- const maxLeft = tabSelectedActual.getBoundingClientRect().left + diff;
68
- const maxRight = tabSelectedActual.getBoundingClientRect().right - diff - tabSelectedActual.clientWidth;
69
-
70
- if (maxLeft < currentX && currentX < maxRight) {
71
- return `translate3d(${currentX}px, ${tabEffectElY}px, 0)`;
72
- }
73
- if (maxLeft > currentX) {
74
- return `translate3d(${maxLeft}px, ${tabEffectElY}px, 0)`;
75
- }
76
- return `translate3d(${maxRight}px, ${tabEffectElY}px, 0)`;
77
- };
78
-
79
- const enterTabButtonAnimation = (detail: GestureDetail): Animation | undefined => {
80
- currentTouchedButton = (detail.event.target as HTMLElement).closest('ion-tab-button');
81
- const tabSelectedActual = ionTabBar.querySelector('ion-tab-button.tab-selected');
82
- if (tabSelectedActual === null || currentTouchedButton === null) {
83
- return undefined;
84
- }
85
-
86
- tabEffectElY = tabSelectedActual.getBoundingClientRect().top;
87
- const startTransform = getTransform(
88
- tabSelectedActual.getBoundingClientRect().left + tabSelectedActual.clientWidth / 2,
89
- tabSelectedActual,
90
- );
91
- const middleTransform = getTransform(
92
- (tabSelectedActual.getBoundingClientRect().left + tabSelectedActual.clientWidth / 2 + detail.currentX) / 2,
93
- currentTouchedButton,
94
- );
95
- const endTransform = getTransform(detail.currentX, currentTouchedButton);
96
- const tabButtonAnimation = createAnimation();
97
- tabButtonAnimation
98
- .addElement(tabEffectEl)
99
- .delay(70)
100
- .beforeStyles({
101
- width: `${tabSelectedActual.clientWidth}px`,
102
- height: `${tabSelectedActual.clientHeight}px`,
103
- display: 'block',
104
- })
105
- .beforeAddWrite(() => {
106
- tabSelectedActual.childNodes.forEach((node) => {
107
- tabEffectEl.appendChild(node.cloneNode(true));
108
- });
109
- currentTouchedButton!.classList.add('ion-activated');
110
- });
111
-
112
- if (currentTouchedButton === tabSelectedActual) {
113
- tabButtonAnimation
114
- .keyframes([
115
- {
116
- transform: `${startTransform} ${MinScale}`,
117
- opacity: 1,
118
- offset: 0,
119
- },
120
- {
121
- transform: `${middleTransform} ${MiddleScale}`,
122
- opacity: 1,
123
- offset: 0.6,
124
- },
125
- {
126
- transform: `${endTransform} ${MaxScale}`,
127
- opacity: 1,
128
- offset: 1,
129
- },
130
- ])
131
- .duration(120);
132
- gestureMoveStartTime = detail.currentTime + 120;
133
- } else {
134
- tabButtonAnimation
135
- .keyframes([
136
- {
137
- transform: `${startTransform} ${MinScale}`,
138
- opacity: 1,
139
- offset: 0,
140
- },
141
- {
142
- transform: `${middleTransform} ${MiddleScale}`,
143
- opacity: 1,
144
- offset: 0.4,
145
- },
146
- {
147
- transform: `${endTransform} ${MaxScale}`,
148
- opacity: 1,
149
- offset: 0.55,
150
- },
151
- {
152
- transform: `${endTransform} ${OverScale}`,
153
- opacity: 1,
154
- offset: 0.75,
155
- },
156
- {
157
- transform: `${endTransform} ${MaxScale}`,
158
- opacity: 1,
159
- offset: 1,
160
- },
161
- ])
162
- .duration(480);
163
- gestureMoveStartTime = detail.currentTime + 480;
164
- }
165
-
166
- return tabButtonAnimation;
167
- };
168
-
169
- const moveTabButtonAnimation = (detail: GestureDetail): Animation | undefined => {
170
- if (gestureMoveStartTime) {
171
- if (detail.currentTime < gestureMoveStartTime) {
172
- return undefined;
173
- }
174
- }
175
- const tabSelectedActual = ionTabBar.querySelector('ion-tab-button.tab-selected');
176
- if (tabSelectedActual === null || currentTouchedButton === null) {
177
- return undefined;
178
- }
179
-
180
- const transform = getTransform(detail.currentX, currentTouchedButton);
181
-
182
- const tabButtonAnimation = createAnimation();
183
- tabButtonAnimation.addElement(tabEffectEl);
184
- tabButtonAnimation.duration(50).keyframes([
185
- {
186
- transform: `${transform} ${MaxScale}`,
187
- },
188
- {
189
- transform: `${transform} ${MaxScale}`,
190
- },
191
- ]);
192
- return tabButtonAnimation;
193
- };
194
-
195
- const leaveTabButtonAnimation = async (detail: GestureDetail): Promise<Animation | undefined> => {
196
- if (gestureMoveStartTime) {
197
- if (detail.currentTime < gestureMoveStartTime) {
198
- await new Promise((resolve) => setTimeout(resolve, gestureMoveStartTime! - detail.currentTime));
199
- }
200
- }
201
- const tabSelectedActual = ionTabBar.querySelector('ion-tab-button.tab-selected');
202
- if (tabSelectedActual === null || currentTouchedButton === null) {
203
- return undefined;
204
- }
205
-
206
- const endTransform = getTransform(
207
- currentTouchedButton.getBoundingClientRect().left + currentTouchedButton.clientWidth / 2,
208
- currentTouchedButton,
209
- );
210
-
211
- const tabButtonAnimation = createAnimation();
212
- tabButtonAnimation.addElement(tabEffectEl);
213
- tabButtonAnimation
214
- .onFinish(() => clearActivated(true))
215
- .duration(50)
216
- .keyframes([
217
- {
218
- transform: `${endTransform} ${MaxScale}`,
219
- opacity: 1,
220
- },
221
- {
222
- transform: `${endTransform} ${MinScale}`,
223
- opacity: 0,
224
- },
225
- ]);
226
- return tabButtonAnimation;
227
- };
228
-
229
- return gesture;
1
+ import { registeredEffect } from './gestures/interfaces';
2
+ import { registerEffect } from './gestures';
3
+ export * from './gestures/interfaces';
4
+
5
+ export const registerTabBarEffect = (targetElement: HTMLElement): registeredEffect | undefined => {
6
+ return registerEffect(targetElement, 'ion-tab-button', 'tab-selected', {
7
+ small: 'scale(1.1)',
8
+ medium: 'scale(1.2)',
9
+ large: 'scale(1.3)',
10
+ xlarge: 'scale(1.3, 1.5)',
11
+ });
230
12
  };
231
13
 
232
- const cloneElement = (tagName: string): HTMLElement => {
233
- const getCachedEl = document.querySelector(`${tagName}.ion-cloned-element`);
234
- if (getCachedEl !== null) {
235
- return getCachedEl as HTMLElement;
236
- }
237
-
238
- const clonedEl = document.createElement(tagName) as HTMLElement;
239
- clonedEl.classList.add('ion-cloned-element');
240
- clonedEl.style.setProperty('display', 'none');
241
- document.body.appendChild(clonedEl);
242
-
243
- return clonedEl;
14
+ export const registerSegmentEffect = (targetElement: HTMLElement): registeredEffect | undefined => {
15
+ return registerEffect(targetElement, 'ion-segment-button', 'segment-button-checked', {
16
+ small: 'scale(1.35)',
17
+ medium: 'scale(1.45)',
18
+ large: 'scale(1.55)',
19
+ xlarge: 'scale(1.55, 1.65)',
20
+ });
244
21
  };
@@ -0,0 +1,106 @@
1
+ @use '../utils/api';
2
+
3
+ ion-segment.ios:not(.ios26-disabled) {
4
+ @include api.glass-background;
5
+ min-height: 48px;
6
+ border-radius: 25px;
7
+
8
+ &.segment-expand {
9
+ min-height: 24px;
10
+ width: calc(100% - var(--ion-safe-area-left, 0) - var(--ion-safe-area-left, 0) - 24px);
11
+
12
+ &.segment-activated {
13
+ transform: scale(1);
14
+ }
15
+
16
+ ion-segment-button {
17
+ min-height: 24px;
18
+ }
19
+ }
20
+
21
+ transition: transform var(--ios26-activated-transition-duration) ease-out;
22
+ will-change: transform;
23
+
24
+ &.in-toolbar-color:not(.in-segment-color) {
25
+ ion-segment-button:not(.segment-button-checked)::part(native) {
26
+ color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 1) !important;
27
+ }
28
+ }
29
+
30
+ &:not(.ios26-enable-gesture).segment-activated {
31
+ transform: scale(1.1);
32
+ ion-segment-button {
33
+ transition: transform 100ms ease-out;
34
+ &.segment-button-checked::part(native) {
35
+ transform: scale(1.08);
36
+ }
37
+ &::part(indicator-background) {
38
+ position: relative;
39
+ z-index: 1;
40
+ background: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0);
41
+ transform: scale(1.1);
42
+ transform-origin: center center;
43
+ }
44
+ }
45
+ }
46
+
47
+ &.ios26-enable-gesture {
48
+ &:has(ion-segment-button.ion-activated) {
49
+ transform: scale(1.1);
50
+ ion-segment-button {
51
+ transition: transform 100ms ease-out;
52
+ &.segment-button-checked::part(native) {
53
+ transform: scale(1.08);
54
+ }
55
+ &::part(indicator-background) {
56
+ position: relative;
57
+ z-index: 1;
58
+ transform: scale(1.1);
59
+ transform-origin: center center;
60
+ }
61
+ }
62
+ }
63
+ &.ios26-animated {
64
+ ion-segment-button {
65
+ &::part(indicator-background) {
66
+ background: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0);
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+
73
+ ion-segment-button.ios:not(.ios26-disabled) {
74
+ --border-width: 0;
75
+ --ion-color-base: var(--ion-text-color, #000);
76
+ --padding-start: 8px;
77
+ --padding-end: 8px;
78
+ min-width: 60px;
79
+ margin: 3px 2px;
80
+ font-size: 14.5px;
81
+
82
+ &::part(indicator-background) {
83
+ border-radius: 25px;
84
+ box-shadow: none;
85
+ transition: background 0.2s ease;
86
+ background: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.06);
87
+ }
88
+
89
+ &.ion-cloned-element {
90
+ &::part(native) {
91
+ border-radius: 25px;
92
+ @include api.glass-background(1, 0, 104%);
93
+ background: transparent;
94
+ height: 100%;
95
+ }
96
+ color: var(--color-selected, var(--ion-color-primary, #0054e9));
97
+ pointer-events: none;
98
+ position: absolute;
99
+ left: 0;
100
+ top: -2.5px;
101
+ transform-origin: center;
102
+ & > * {
103
+ visibility: hidden;
104
+ }
105
+ }
106
+ }
@@ -46,7 +46,7 @@ ion-tab-bar.ios:not(.ios26-disabled) {
46
46
  /**
47
47
  * effectが有効な場合、effectでスタイリングするため不要
48
48
  */
49
- &.tab-bar-ios26-effect:has(ion-tab-button.ion-activated) {
49
+ &.ios26-enable-gesture.ios26-animated {
50
50
  ion-tab-button.tab-selected::part(native) {
51
51
  background: rgba(var(--ios26-button-color-selected-rgb), 0);
52
52
  }
@@ -101,7 +101,7 @@ ion-tab-button.ios:not(.ios26-disabled) {
101
101
 
102
102
  &.ion-cloned-element {
103
103
  &::part(native) {
104
- @include api.glass-background(1, 2px, 104%);
104
+ @include api.glass-background(1, 0, 104%);
105
105
  background: transparent;
106
106
  }
107
107
  color: var(--color-selected, var(--ion-color-primary, #0054e9));
@@ -13,12 +13,12 @@ ion-toolbar.md:not(.ios26-disabled) {
13
13
  }
14
14
  }
15
15
 
16
- ion-buttons.md.ios26-disabled {
16
+ ion-buttons.md {
17
17
  /**
18
18
  * ion-buttons.ios26-disabled > ion-button.button-default is for ios26 structure.
19
19
  * for .md, remove button-default styles. Will be button-clear.
20
20
  */
21
- ion-button:not(.ios26-disabled).button-default {
21
+ ion-button.md:not(.ios26-disabled).button-default {
22
22
  // copy .button-clear
23
23
  --color: initial;
24
24
  --background: transparent;
@@ -1,64 +0,0 @@
1
- @use '../utils/api';
2
-
3
- ion-segment.ios:not(.ios26-disabled) {
4
- @include api.glass-background;
5
- min-height: 48px;
6
- border-radius: 25px;
7
-
8
- &.segment-expand {
9
- min-height: 24px;
10
- width: calc(100% - var(--ion-safe-area-left, 0) - var(--ion-safe-area-left, 0) - 24px);
11
-
12
- &.segment-activated {
13
- transform: scale(1);
14
- }
15
-
16
- ion-segment-button {
17
- min-height: 24px;
18
- }
19
- }
20
-
21
- transition: transform var(--ios26-activated-transition-duration) ease-out;
22
- will-change: transform;
23
-
24
- &.in-toolbar-color:not(.in-segment-color) {
25
- ion-segment-button:not(.segment-button-checked)::part(native) {
26
- color: rgba(var(--ion-text-color-rgb, 0, 0, 0), 1) !important;
27
- }
28
- }
29
-
30
- ion-segment-button {
31
- --border-width: 0;
32
- --ion-color-base: var(--ion-text-color, #000);
33
- --padding-start: 8px;
34
- --padding-end: 8px;
35
- min-width: 60px;
36
- margin: 3px 2px;
37
- font-size: 14.5px;
38
-
39
- &::part(indicator-background) {
40
- border-radius: 25px;
41
- box-shadow: none;
42
- transition: background 0.2s ease;
43
- background: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.06);
44
- }
45
- }
46
-
47
- &.segment-activated {
48
- transform: scale(1.1);
49
-
50
- ion-segment-button {
51
- transition: transform 100ms ease-out;
52
- &.segment-button-checked::part(native) {
53
- transform: scale(1.08);
54
- }
55
- &::part(indicator-background) {
56
- position: relative;
57
- z-index: 1;
58
- background: rgba(var(--ion-text-color-rgb, 0, 0, 0), 0);
59
- transform: scale(1.1);
60
- transform-origin: center center;
61
- }
62
- }
63
- }
64
- }
File without changes
File without changes
File without changes
File without changes
File without changes