Skip to content

Commit 1e919d9

Browse files
authored
Merge pull request #335 from kit-data-manager/design-improvements
Design improvements
2 parents 8071137 + c1e65a8 commit 1e919d9

File tree

9 files changed

+127
-81
lines changed

9 files changed

+127
-81
lines changed

packages/react-library/lib/components/stencil-generated/components.server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export const PidCollapsible: StencilReactComponent<PidCollapsibleElement, PidCol
9696
open: 'open',
9797
emphasize: 'emphasize',
9898
darkMode: 'dark-mode',
99-
expanded: 'expanded',
10099
initialWidth: 'initial-width',
101100
initialHeight: 'initial-height',
102101
lineHeight: 'line-height',

packages/stencil-library/src/components.d.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ export namespace Components {
116116
* @default false
117117
*/
118118
"emphasize": boolean;
119-
/**
120-
* Whether the component is in expanded mode (full size)
121-
* @default false
122-
*/
123-
"expanded": boolean;
124119
/**
125120
* Initial height when expanded
126121
*/
@@ -135,7 +130,8 @@ export namespace Components {
135130
*/
136131
"lineHeight": number;
137132
/**
138-
* Whether the collapsible is open by default
133+
* Whether the collapsible is open
134+
* @description Controls whether the component is expanded (opened) or collapsed
139135
* @default false
140136
*/
141137
"open": boolean;
@@ -575,11 +571,6 @@ declare namespace LocalJSX {
575571
* @default false
576572
*/
577573
"emphasize"?: boolean;
578-
/**
579-
* Whether the component is in expanded mode (full size)
580-
* @default false
581-
*/
582-
"expanded"?: boolean;
583574
/**
584575
* Initial height when expanded
585576
*/
@@ -602,7 +593,8 @@ declare namespace LocalJSX {
602593
*/
603594
"onContentHeightChange"?: (event: PidCollapsibleCustomEvent<{ maxHeight: number }>) => void;
604595
/**
605-
* Whether the collapsible is open by default
596+
* Whether the collapsible is open
597+
* @description Controls whether the component is expanded (opened) or collapsed
606598
* @default false
607599
*/
608600
"open"?: boolean;

packages/stencil-library/src/components/pid-collapsible/collapsible.css

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,23 @@ pid-collapsible.resize-both {
5454
-webkit-resize: both !important;
5555
resize: both !important;
5656
overflow: auto !important;
57+
position: relative !important;
58+
}
59+
60+
/* Enhanced resize handle for Safari */
61+
pid-collapsible.resize-both::after {
62+
content: '';
63+
position: absolute;
64+
bottom: 0;
65+
right: 0;
66+
width: 15px;
67+
height: 15px;
68+
background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M22 2L2 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M22 8L8 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M22 14L14 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
69+
background-repeat: no-repeat;
70+
background-position: bottom right;
71+
cursor: nwse-resize;
72+
z-index: 10;
73+
pointer-events: none;
5774
}
5875
}
5976
}
@@ -68,11 +85,14 @@ pid-collapsible.resize-both::after {
6885
position: absolute;
6986
bottom: 0;
7087
right: 0;
71-
width: 10px;
72-
height: 10px;
88+
width: 15px;
89+
height: 15px;
7390
cursor: nwse-resize;
74-
background: linear-gradient(-45deg, rgba(0, 0, 0, 0.1) 0%, rgba(0, 0, 0, 0.1) 50%, transparent 50%);
91+
background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M22 2L2 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M22 8L8 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M22 14L14 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
92+
background-repeat: no-repeat;
93+
background-position: bottom right;
7594
z-index: 10; /* Ensure resize handle is above other elements */
95+
pointer-events: none;
7696
}
7797

7898
/*
@@ -150,13 +170,13 @@ pid-collapsible.resize-both::after {
150170

151171
/* Ensure resize works in Safari */
152172
pid-collapsible.resize-both {
153-
position: relative;
173+
/*position: relative;*/
154174
-webkit-resize: both !important;
155-
resize: both !important;
156-
overflow: auto !important;
157-
max-width: 100% !important;
158-
max-height: 90vh !important;
159-
display: block !important;
175+
/*resize: both !important;*/
176+
/*overflow: auto !important;*/
177+
/*max-width: 100% !important;*/
178+
/*max-height: 90vh !important;*/
179+
/*display: block !important;*/
160180
}
161181

162182
/* Enhanced resize handle visibility for Safari */
@@ -168,9 +188,14 @@ pid-collapsible.resize-both::after {
168188
width: 15px;
169189
height: 15px;
170190
cursor: nwse-resize;
171-
background: linear-gradient(-45deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.2) 50%, transparent 50%);
191+
background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M22 2L2 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M22 8L8 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M22 14L14 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
192+
background-repeat: no-repeat;
193+
background-position: bottom right;
172194
z-index: 10;
195+
pointer-events: none;
173196
}
197+
198+
174199
}
175200

176201
/*
@@ -228,8 +253,8 @@ pid-collapsible.resize-both::after {
228253
}
229254

230255
pid-collapsible.resize-both::after {
231-
background: currentColor;
232-
opacity: 0.5;
256+
background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M22 2L2 22' stroke='currentColor' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M22 8L8 22' stroke='currentColor' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M22 14L14 22' stroke='currentColor' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
257+
opacity: 0.9;
233258
}
234259
}
235260

packages/stencil-library/src/components/pid-collapsible/pid-collapsible.stories.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,6 @@ export const CollapsibleStates: Story = {
522522
title: 'Expanded',
523523
open: true,
524524
emphasize: true,
525-
expanded: true,
526525
showFooter: true,
527526
darkMode: 'system',
528527
description: 'Open, emphasized, expanded state with footer.',

packages/stencil-library/src/components/pid-collapsible/pid-collapsible.tsx

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ export class PidCollapsible {
4949
@Element() el: HTMLElement;
5050

5151
/**
52-
* Whether the collapsible is open by default
52+
* Whether the collapsible is open
53+
* @description Controls whether the component is expanded (opened) or collapsed
5354
*/
54-
@Prop() open: boolean = false;
55+
@Prop({ mutable: true }) open: boolean = false;
5556

5657
/**
5758
* Whether to emphasize the component with border and shadow
@@ -65,11 +66,6 @@ export class PidCollapsible {
6566
*/
6667
@Prop() darkMode: 'light' | 'dark' | 'system' = 'system';
6768

68-
/**
69-
* Whether the component is in expanded mode (full size)
70-
*/
71-
@Prop({ mutable: true }) expanded: boolean = false;
72-
7369
/**
7470
* Initial width when expanded
7571
*/
@@ -136,24 +132,10 @@ export class PidCollapsible {
136132
*/
137133
@Watch('open')
138134
watchOpen() {
139-
this.expanded = this.open;
140135
this.updateAppearance();
141-
}
142136

143-
/**
144-
* Watch for changes in the expanded property
145-
*/
146-
@Watch('expanded')
147-
watchExpanded() {
148-
this.updateAppearance();
149-
150-
// When expanded, ensure content dimensions are properly calculated
151-
if (this.expanded) {
152-
// Use setTimeout to ensure DOM is updated before recalculating
153-
setTimeout(() => {
154-
this.recalculateContentDimensions();
155-
}, 0);
156-
}
137+
// When open, ensure content dimensions are properly calculated
138+
if (this.open) this.recalculateContentDimensions();
157139
}
158140

159141
/**
@@ -165,8 +147,6 @@ export class PidCollapsible {
165147
}
166148

167149
componentWillLoad() {
168-
// Initialize state from props
169-
this.expanded = this.open;
170150
// Default to 75% width if no initial width is provided
171151
this.currentWidth = this.initialWidth || '75%'; // Changed from DEFAULT_WIDTH to use 75% (w-3/4)
172152
this.currentHeight = this.initialHeight || CONSTANTS.DEFAULT_HEIGHT;
@@ -181,6 +161,18 @@ export class PidCollapsible {
181161
this.addBrowserCompatibilityListeners();
182162
this.addComponentEventListeners();
183163

164+
// // When component is initially open, ensure dimensions are properly calculated after rendering
165+
// if (this.open) {
166+
// // // Make sure expanded state is set correctly for open components
167+
// // this.open = true;
168+
//
169+
// // Use a small delay to ensure the DOM is fully rendered
170+
// setTimeout(() => {
171+
// // Force recalculation of dimensions for open components
172+
// this.recalculateContentDimensions();
173+
// }, 100);
174+
// }
175+
184176
// Add clearfix for Safari - prevent text flow issues
185177
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
186178
this.el.style.display = 'inline-block';
@@ -293,7 +285,7 @@ export class PidCollapsible {
293285
*/
294286
@Method()
295287
public async recalculateContentDimensions() {
296-
if (this.expanded) {
288+
if (this.open) {
297289
// Add a class to optimize rendering during recalculation
298290
this.el.classList.add('resizing');
299291

@@ -382,7 +374,7 @@ export class PidCollapsible {
382374
// Create new observer with debouncing for better performance
383375
this.resizeObserver = new ResizeObserver(entries => {
384376
// Only track dimensions when expanded
385-
if (!this.expanded) return;
377+
if (!this.open) return;
386378

387379
// Get the entry from the first parameter
388380
const entry = entries[0];
@@ -414,7 +406,7 @@ export class PidCollapsible {
414406
});
415407

416408
// Start observing if expanded
417-
if (this.expanded) {
409+
if (this.open) {
418410
this.resizeObserver.observe(this.el);
419411
}
420412
}
@@ -519,7 +511,7 @@ export class PidCollapsible {
519511
// Reset all classes and styles before applying new ones
520512
this.resetStyles();
521513

522-
if (this.expanded) {
514+
if (this.open) {
523515
this.applyExpandedStyles();
524516
} else {
525517
this.applyCollapsedStyles();
@@ -751,20 +743,25 @@ export class PidCollapsible {
751743
}
752744

753745
// Toggle expanded state
754-
this.expanded = !this.expanded;
755-
details.open = this.expanded;
746+
this.open = !this.open;
747+
details.open = this.open;
756748

757749
// Emit event
758-
this.collapsibleToggle.emit(this.expanded);
750+
this.collapsibleToggle.emit(this.open);
759751

760752
// Update appearance
761753
this.updateAppearance();
762754

755+
// For Safari compatibility - ensure content recalculation when expanding
756+
if (this.open && this.isSafari()) {
757+
setTimeout(() => {
758+
this.recalculateContentDimensions();
759+
}, 50);
760+
}
761+
763762
// Ensure consistent state and reset flag
764763
setTimeout(() => {
765-
if (details.open !== this.expanded) {
766-
details.open = this.expanded;
767-
}
764+
details.open = this.open;
768765
setTimeout(() => {
769766
this.isToggling = false;
770767
}, 100);
@@ -793,7 +790,7 @@ export class PidCollapsible {
793790
}
794791

795792
// Add state-specific classes
796-
if (this.expanded) {
793+
if (this.open) {
797794
baseClasses.push('mb-2', 'max-w-full', 'text-xs', 'block');
798795
} else {
799796
baseClasses.push('my-0', 'text-sm', 'float-left');
@@ -813,7 +810,7 @@ export class PidCollapsible {
813810
private getDetailsClasses() {
814811
const baseClasses = ['group', 'w-full', 'font-sans', 'transition-all', 'duration-200', 'ease-in-out', 'flex', 'flex-col'];
815812

816-
if (this.expanded) {
813+
if (this.open) {
817814
baseClasses.push('h-full', 'overflow-visible');
818815
} else {
819816
baseClasses.push('text-clip', 'overflow-hidden');
@@ -849,7 +846,7 @@ export class PidCollapsible {
849846
'box-border',
850847
];
851848

852-
if (this.expanded) {
849+
if (this.open) {
853850
if (this.isDarkMode) {
854851
baseClasses.push('sticky', 'top-0', 'bg-gray-800', `z-${Z_INDICES.STICKY_ELEMENTS}`, 'border-b', 'border-gray-700', 'px-2', 'py-0', 'overflow-visible', 'backdrop-blur-sm');
855852
} else {
@@ -871,7 +868,7 @@ export class PidCollapsible {
871868
private getContentClasses() {
872869
const baseClasses = ['flex-grow', 'flex', 'flex-col', 'min-h-0'];
873870

874-
if (this.expanded) {
871+
if (this.open) {
875872
baseClasses.push('overflow-auto', 'p-2');
876873
} else {
877874
baseClasses.push('overflow-hidden', 'p-0');
@@ -944,7 +941,7 @@ export class PidCollapsible {
944941
e.stopImmediatePropagation();
945942
}}
946943
>
947-
<span class={`inline-flex h-full items-center gap-1 pr-2 ${this.expanded ? 'flex-nowrap whitespace-nowrap' : 'min-w-0 flex-nowrap overflow-hidden'}`}>
944+
<span class={`inline-flex h-full items-center gap-1 pr-2 ${this.open ? 'flex-nowrap whitespace-nowrap' : 'min-w-0 flex-nowrap overflow-hidden'}`}>
948945
{this.emphasize && (
949946
<span class="flex h-full flex-shrink-0 items-center">
950947
<svg
@@ -963,7 +960,7 @@ export class PidCollapsible {
963960
</svg>
964961
</span>
965962
)}
966-
<span class={`${this.expanded ? 'overflow-visible' : 'min-w-0 truncate'} flex h-full items-center`}>
963+
<span class={`${this.open ? 'overflow-visible' : 'min-w-0 truncate'} flex h-full items-center`}>
967964
<slot name="summary"></slot>
968965
</span>
969966
</span>
@@ -976,7 +973,7 @@ export class PidCollapsible {
976973
<slot></slot>
977974
</div>
978975

979-
{this.showFooter && this.expanded && (
976+
{this.showFooter && this.open && (
980977
<div class={footerClasses}>
981978
{/* Main footer slot for pagination */}
982979
<div class={`z-50 overflow-visible border-b ${this.isDarkMode ? 'border-gray-700 bg-gray-800' : 'border-gray-100 bg-white'}`}>

packages/stencil-library/src/components/pid-collapsible/readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ with resize capability and cross-browser compatibility
6363
| --------------- | ---------------- | -------------------------------------------------------------------------------------------- | ------------------------------- | ----------- |
6464
| `darkMode` | `dark-mode` | The dark mode setting for the component Options: "light", "dark", "system" Default: "system" | `"dark" \| "light" \| "system"` | `'system'` |
6565
| `emphasize` | `emphasize` | Whether to emphasize the component with border and shadow | `boolean` | `false` |
66-
| `expanded` | `expanded` | Whether the component is in expanded mode (full size) | `boolean` | `false` |
6766
| `initialHeight` | `initial-height` | Initial height when expanded | `string` | `undefined` |
6867
| `initialWidth` | `initial-width` | Initial width when expanded | `string` | `undefined` |
6968
| `lineHeight` | `line-height` | Line height for collapsed state | `number` | `24` |
70-
| `open` | `open` | Whether the collapsible is open by default | `boolean` | `false` |
69+
| `open` | `open` | Whether the collapsible is open | `boolean` | `false` |
7170
| `showFooter` | `show-footer` | Whether to show the footer section | `boolean` | `false` |
7271

7372

packages/stencil-library/src/components/pid-component/pid-component.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,22 @@ pid-component {
3232
-webkit-resize: both !important;
3333
resize: both !important;
3434
overflow: auto !important;
35+
position: relative !important;
36+
}
37+
38+
/* Add visible resize handle for Safari */
39+
pid-component pid-collapsible.resize-both::after {
40+
content: '';
41+
position: absolute;
42+
bottom: 0;
43+
right: 0;
44+
width: 15px;
45+
height: 15px;
46+
background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M22 2L2 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M22 8L8 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3Cpath d='M22 14L14 22' stroke='currentColor' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
47+
background-repeat: no-repeat;
48+
background-position: bottom right;
49+
cursor: nwse-resize;
50+
z-index: 10;
51+
pointer-events: none;
3552
}
3653
}

0 commit comments

Comments
 (0)