Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdab7174

Browse files
committed
[FIX]#1626 add min-width using css grid minmax()
1 parent603a62d commitdab7174

File tree

1 file changed

+54
-1
lines changed

1 file changed

+54
-1
lines changed

‎client/packages/lowcoder/src/comps/comps/columnLayout/columnLayout.tsx

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,53 @@ const ColumnContainer = (props: ColumnContainerProps) => {
123123
);
124124
};
125125

126+
// Function to apply min-widths to grid template columns
127+
constapplyMinWidthsToGridColumns=(columnsDef:string,minWidths:(string|null)[]=[])=>{
128+
// Handle empty case
129+
if(!columnsDef?.trim())return'';
130+
131+
// Handle repeat() functions with special parsing
132+
if(columnsDef.includes('repeat(')){
133+
// For complex repeat patterns, we should return as-is to avoid breaking the layout
134+
// A more complex parser would be needed to fully support repeat with minmax
135+
returncolumnsDef;
136+
}
137+
138+
constcolumns=columnsDef.trim().split(/\s+/);
139+
140+
constnewColumns=columns.map((col,index)=>{
141+
constminWidth=minWidths[index];
142+
143+
// Skip if no minWidth provided for this column
144+
if(!minWidth){
145+
returncol;
146+
}
147+
148+
// Keywords that should never be wrapped in minmax()
149+
constkeywords=['auto','min-content','max-content','fit-content','subgrid'];
150+
if(keywords.some(keyword=>col===keyword)){
151+
returncol;
152+
}
153+
154+
// Functions that should never be wrapped in minmax()
155+
if(col.includes('(')&&col.includes(')')){
156+
// Already includes a function like calc(), minmax(), etc.
157+
returncol;
158+
}
159+
160+
// Determine if column is flexible and can be wrapped with minmax
161+
// - fr units (e.g., "1fr", "2.5fr")
162+
// - percentage values (e.g., "50%")
163+
// - length values (px, em, rem, etc.)
164+
constisFlexible=/fr$/.test(col)||
165+
/%$/.test(col)||
166+
/^\d+(\.\d+)?(px|em|rem|vh|vw|vmin|vmax|cm|mm|in|pt|pc)$/.test(col);
167+
168+
returnisFlexible ?`minmax(${minWidth},${col})` :col;
169+
});
170+
171+
returnnewColumns.join(' ');
172+
};
126173

127174
constColumnLayout=(props:ColumnLayoutProps)=>{
128175
let{
@@ -139,6 +186,12 @@ const ColumnLayout = (props: ColumnLayoutProps) => {
139186
mainScrollbar
140187
}=props;
141188

189+
// Extract minWidths from columns
190+
constminWidths=columns.map(column=>column.minWidth||null);
191+
192+
// Apply min-widths to grid template columns
193+
constgridTemplateColumns=applyMinWidthsToGridColumns(templateColumns,minWidths);
194+
142195
return(
143196
<BackgroundColorContext.Providervalue={props.style.background}>
144197
<DisabledContext.Providervalue={props.disabled}>
@@ -147,7 +200,7 @@ const ColumnLayout = (props: ColumnLayoutProps) => {
147200
<ContainWrapper$style={{
148201
...props.style,
149202
display:"grid",
150-
gridTemplateColumns:templateColumns,
203+
gridTemplateColumns:gridTemplateColumns,
151204
columnGap,
152205
gridTemplateRows:templateRows,
153206
rowGap,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp