Skip to content

Commit 575ea4f

Browse files
added hover and active color options in link styles
1 parent 990ff84 commit 575ea4f

File tree

7 files changed

+118
-16
lines changed

7 files changed

+118
-16
lines changed

client/packages/lowcoder/src/comps/comps/buttonComp/linkComp.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,18 @@ import { EditorContext } from "comps/editorState";
2424
import React, { useContext } from "react";
2525

2626
const Link = styled(Button)<{ $style: LinkStyleType }>`
27-
${(props) => `color: ${props.$style.text}; margin: ${props.$style.margin}; padding: ${props.$style.padding}; font-size: ${props.$style.textSize};`}
27+
${(props) => `
28+
color: ${props.$style.text};
29+
margin: ${props.$style.margin};
30+
padding: ${props.$style.padding};
31+
font-size: ${props.$style.textSize};
32+
&:hover {
33+
color: ${props.$style.hoverText} !important;
34+
}
35+
&:active {
36+
color: ${props.$style.activeText} !important;
37+
}
38+
`}
2839
&.ant-btn {
2940
display: inline-flex;
3041
align-items: center;

client/packages/lowcoder/src/comps/comps/tableComp/column/columnTypeCompBuilder.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ export class ColumnTypeCompBuilder<
5050
private propertyViewFn?: PropertyViewFnTypeForComp<
5151
RecordConstructorToComp<NewChildrenCtorMap<ChildrenCtorMap, T>>
5252
>;
53+
private stylePropertyViewFn?: PropertyViewFnTypeForComp<
54+
RecordConstructorToComp<NewChildrenCtorMap<ChildrenCtorMap, T>>
55+
>;
5356
private editViewFn?: EditViewFn<T>;
5457

5558
constructor(
@@ -77,6 +80,15 @@ export class ColumnTypeCompBuilder<
7780
return this;
7881
}
7982

83+
setStylePropertyViewFn(
84+
stylePropertyViewFn: PropertyViewFnTypeForComp<
85+
RecordConstructorToComp<NewChildrenCtorMap<ChildrenCtorMap, T>>
86+
>
87+
) {
88+
this.stylePropertyViewFn = stylePropertyViewFn;
89+
return this;
90+
}
91+
8092
build() {
8193
if (!this.propertyViewFn) {
8294
throw new Error("need property view fn");

client/packages/lowcoder/src/comps/comps/tableComp/column/columnTypeComps/columnLinkComp.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import { BoolCodeControl, StringControl } from "comps/controls/codeControl";
88
import { trans } from "i18n";
99
import { disabledPropertyView } from "comps/utils/propertyUtils";
1010
import styled, { css } from "styled-components";
11+
import { styleControl } from "comps/controls/styleControl";
12+
import { TableColumnLinkStyle } from "comps/controls/styleControlConstants";
1113

1214
export const ColumnValueTooltip = trans("table.columnValueTooltip");
1315

1416
const childrenMap = {
1517
text: StringControl,
1618
onClick: ActionSelectorControlInContext,
1719
disabled: BoolCodeControl,
20+
style: styleControl(TableColumnLinkStyle),
1821
};
1922

2023
const disableCss = css`
@@ -78,5 +81,10 @@ export const LinkComp = (function () {
7881
})}
7982
</>
8083
))
84+
.setStylePropertyViewFn((children) => (
85+
<>
86+
{children.style.getPropertyView()}
87+
</>
88+
))
8189
.build();
8290
})();

client/packages/lowcoder/src/comps/comps/tableComp/column/tableColumnComp.tsx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ import { ColorControl } from "comps/controls/colorControl";
2727
import { JSONValue } from "util/jsonTypes";
2828
import styled from "styled-components";
2929
import { TextOverflowControl } from "comps/controls/textOverflowControl";
30+
import { TableColumnLinkStyle, styleControl } from "@lowcoder-ee/index.sdk";
31+
import { Divider } from "antd";
3032

3133
export type Render = ReturnType<ConstructorToComp<typeof RenderComp>["getOriginalComp"]>;
3234
export const RenderComp = withSelectedMultiContext(ColumnTypeComp);
@@ -106,6 +108,9 @@ export const columnChildrenMap = {
106108
textSize: withDefault(RadiusControl, ""),
107109
cellColor: CellColorComp,
108110
textOverflow: withDefault(TextOverflowControl, "ellipsis"),
111+
linkColor: withDefault(ColorControl, "#3377ff"),
112+
linkHoverColor: withDefault(ColorControl, ""),
113+
linkActiveColor: withDefault(ColorControl, ""),
109114
};
110115

111116
const StyledIcon = styled.span`
@@ -201,15 +206,36 @@ export class ColumnComp extends ColumnInitComp {
201206
})}
202207
{this.children.autoWidth.getView() === "fixed" &&
203208
this.children.width.propertyView({ label: trans("prop.width") })}
209+
210+
{(columnType === 'link' || columnType === 'links') && (
211+
<>
212+
<Divider style={{margin: '12px 0'}} />
213+
{controlItem({}, (
214+
<div>
215+
<b>{"Link Style"}</b>
216+
</div>
217+
))}
218+
{this.children.linkColor.propertyView({
219+
label: trans('text') // trans('style.background'),
220+
})}
221+
{this.children.linkHoverColor.propertyView({
222+
label: "Hover text", // trans('style.background'),
223+
})}
224+
{this.children.linkActiveColor.propertyView({
225+
label: "Active text", // trans('style.background'),
226+
})}
227+
</>
228+
)}
229+
<Divider style={{margin: '12px 0'}} />
204230
{controlItem({}, (
205-
<div style={{marginTop: '8px'}}>
206-
<b>{"Style"}</b>
231+
<div>
232+
<b>{"Column Style"}</b>
207233
</div>
208234
))}
209235
{this.children.background.propertyView({
210236
label: trans('style.background'),
211237
})}
212-
{this.children.text.propertyView({
238+
{columnType !== 'link' && this.children.text.propertyView({
213239
label: trans('text'),
214240
})}
215241
{this.children.border.propertyView({

client/packages/lowcoder/src/comps/comps/tableComp/tableCompView.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
defaultTheme,
1818
handleToHoverRow,
1919
handleToSelectedRow,
20+
TableColumnLinkStyleType,
2021
TableColumnStyleType,
2122
TableRowStyleType,
2223
TableStyleType,
@@ -285,6 +286,7 @@ const TableTh = styled.th<{ width?: number }>`
285286
const TableTd = styled.td<{
286287
background: string;
287288
$style: TableColumnStyleType & {rowHeight?: string};
289+
$linkStyle?: TableColumnLinkStyleType;
288290
$isEditing: boolean;
289291
$tableSize?: string;
290292
$autoHeight?: boolean;
@@ -345,11 +347,15 @@ const TableTd = styled.td<{
345347
346348
// dark link|links color
347349
> a,
348-
> div > a {
349-
color: ${(props) => isDarkColor(props.background) && "#A6FFFF"};
350+
> div a {
351+
color: ${(props) => props.$linkStyle?.text};
350352
351353
&:hover {
352-
color: ${(props) => isDarkColor(props.background) && "#2EE6E6"};
354+
color: ${(props) => props.$linkStyle?.hoverText};
355+
}
356+
357+
&:active {
358+
color: ${(props) => props.$linkStyle?.activeText}};
353359
}
354360
}
355361
}
@@ -431,6 +437,7 @@ function TableCellView(props: {
431437
children: any;
432438
columnsStyle: TableColumnStyleType;
433439
columnStyle: TableColumnStyleType;
440+
linkStyle: TableColumnLinkStyleType;
434441
tableSize?: string;
435442
autoHeight?: boolean;
436443
}) {
@@ -444,6 +451,7 @@ function TableCellView(props: {
444451
children,
445452
columnsStyle,
446453
columnStyle,
454+
linkStyle,
447455
tableSize,
448456
autoHeight,
449457
...restProps
@@ -492,6 +500,7 @@ function TableCellView(props: {
492500
{...restProps}
493501
background={background}
494502
$style={style}
503+
$linkStyle={linkStyle}
495504
$isEditing={editing}
496505
$tableSize={tableSize}
497506
$autoHeight={autoHeight}
@@ -535,7 +544,7 @@ function ResizeableTable<RecordType extends object>(props: CustomTableProps<Reco
535544
});
536545
let allColumnFixed = true;
537546
const columns = props.columns.map((col, index) => {
538-
const { width, style, cellColorFn, ...restCol } = col;
547+
const { width, style, linkStyle, cellColorFn, ...restCol } = col;
539548
const resizeWidth = (resizeData.index === index ? resizeData.width : col.width) ?? 0;
540549
let colWidth: number | string = "auto";
541550
let minWidth: number | string = COL_MIN_WIDTH;
@@ -567,6 +576,7 @@ function ResizeableTable<RecordType extends object>(props: CustomTableProps<Reco
567576
rowIndex: rowIndex,
568577
columnsStyle: props.columnsStyle,
569578
columnStyle: style,
579+
linkStyle,
570580
tableSize: props.size,
571581
autoHeight: props.rowAutoHeight,
572582
}),

client/packages/lowcoder/src/comps/comps/tableComp/tableUtils.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { tryToNumber } from "util/convertUtils";
1717
import { JSONObject, JSONValue } from "util/jsonTypes";
1818
import { StatusType } from "./column/columnTypeComps/columnStatusComp";
1919
import { ColumnListComp, tableDataRowExample } from "./column/tableColumnListComp";
20-
import { TableColumnStyleType } from "comps/controls/styleControlConstants";
20+
import { TableColumnLinkStyleType, TableColumnStyleType } from "comps/controls/styleControlConstants";
2121

2222
export const COLUMN_CHILDREN_KEY = "children";
2323
export const OB_ROW_ORI_INDEX = "__ob_origin_index";
@@ -254,6 +254,7 @@ export type CustomColumnType<RecordType> = ColumnType<RecordType> & {
254254
onWidthResize?: (width: number) => void;
255255
titleText: string;
256256
style: TableColumnStyleType;
257+
linkStyle: TableColumnLinkStyleType;
257258
cellColorFn: CellColorViewType;
258259
};
259260

@@ -324,6 +325,11 @@ export function columnsToAntdFormat(
324325
textSize: column.textSize,
325326
borderWidth: column.borderWidth,
326327
},
328+
linkStyle: {
329+
text: column.linkColor,
330+
hoverText: column.linkHoverColor,
331+
activeText: column.linkActiveColor,
332+
},
327333
cellColorFn: column.cellColor,
328334
onWidthResize: column.onWidthResize,
329335
render: (value: any, record: RecordType, index: number) => {

client/packages/lowcoder/src/comps/controls/styleControlConstants.tsx

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,28 @@ export const SegmentStyle = [
660660
PADDING,
661661
] as const;
662662

663+
const LinkTextStyle = [
664+
{
665+
name: "text",
666+
label: trans("text"),
667+
depTheme: "primary",
668+
depType: DEP_TYPE.SELF,
669+
transformer: toSelf,
670+
},
671+
{
672+
name: "hoverText",
673+
label: "Hover text", // trans("style.hoverRowBackground"),
674+
depName: "text",
675+
transformer: handleToHoverLink,
676+
},
677+
{
678+
name: "activeText",
679+
label: "Active text", // trans("style.hoverRowBackground"),
680+
depName: "text",
681+
transformer: handleToHoverLink,
682+
},
683+
] as const;
684+
663685
export const TableStyle = [
664686
...BG_STATIC_BORDER_RADIUS,
665687
{
@@ -724,6 +746,10 @@ export const TableColumnStyle = [
724746
TEXT_SIZE,
725747
] as const;
726748

749+
export const TableColumnLinkStyle = [
750+
...LinkTextStyle,
751+
] as const;
752+
727753
export const FileStyle = [...getStaticBgBorderRadiusByBg(SURFACE_COLOR), TEXT, ACCENT, MARGIN, PADDING] as const;
728754

729755
export const FileViewerStyle = [
@@ -746,14 +772,16 @@ export const DateTimeStyle = [
746772
...ACCENT_VALIDATE,
747773
] as const;
748774

775+
function handleToHoverLink(color: string) {
776+
if (isDarkColor(color)) {
777+
return "#FFFFFF23";
778+
} else {
779+
return "#00000007";
780+
}
781+
}
782+
749783
export const LinkStyle = [
750-
{
751-
name: "text",
752-
label: trans("text"),
753-
depTheme: "primary",
754-
depType: DEP_TYPE.SELF,
755-
transformer: toSelf,
756-
},
784+
...LinkTextStyle,
757785
MARGIN,
758786
PADDING,
759787
TEXT_SIZE
@@ -1047,6 +1075,7 @@ export type SegmentStyleType = StyleConfigType<typeof SegmentStyle>;
10471075
export type TableStyleType = StyleConfigType<typeof TableStyle>;
10481076
export type TableRowStyleType = StyleConfigType<typeof TableRowStyle>;
10491077
export type TableColumnStyleType = StyleConfigType<typeof TableColumnStyle>;
1078+
export type TableColumnLinkStyleType = StyleConfigType<typeof TableColumnLinkStyle>;
10501079
export type FileStyleType = StyleConfigType<typeof FileStyle>;
10511080
export type FileViewerStyleType = StyleConfigType<typeof FileViewerStyle>;
10521081
export type IframeStyleType = StyleConfigType<typeof IframeStyle>;

0 commit comments

Comments
 (0)