forked from AykutSarac/jsoncrack.com
-
Notifications
You must be signed in to change notification settings - Fork 338
Expand file tree
/
Copy pathstyles.tsx
More file actions
127 lines (112 loc) · 3.11 KB
/
styles.tsx
File metadata and controls
127 lines (112 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import type { DefaultTheme } from "styled-components";
import styled from "styled-components";
import { LinkItUrl } from "react-linkify-it";
import { NODE_DIMENSIONS } from "../../../../../constants/graph";
type TextColorFn = {
theme: DefaultTheme;
$type?: string;
$value?: string | number | null | boolean;
};
function getTextColor({ $value, $type, theme }: TextColorFn) {
if ($value === null) return theme.NODE_COLORS.NULL;
if ($type === "object") return theme.NODE_COLORS.NODE_KEY;
if ($type === "number") return theme.NODE_COLORS.INTEGER;
if ($value === true) return theme.NODE_COLORS.BOOL.TRUE;
if ($value === false) return theme.NODE_COLORS.BOOL.FALSE;
return theme.NODE_COLORS.NODE_VALUE;
}
export const StyledLinkItUrl = styled(LinkItUrl)`
text-decoration: underline;
pointer-events: all;
`;
export const StyledForeignObject = styled.foreignObject<{ $isObject?: boolean }>`
text-align: ${({ $isObject }) => !$isObject && "center"};
color: ${({ theme }) => theme.NODE_COLORS.TEXT};
font-family: monospace;
font-size: 12px;
font-weight: 500;
overflow: hidden;
pointer-events: none;
&.searched {
background: rgba(27, 255, 0, 0.1);
border: 1px solid ${({ theme }) => theme.TEXT_POSITIVE};
border-radius: 2px;
box-sizing: border-box;
}
.highlight {
background: rgba(255, 214, 0, 0.15);
}
.renderVisible {
display: flex;
justify-content: center;
align-items: center;
font-size: 12px;
width: 100%;
height: 100%;
overflow: hidden;
cursor: pointer;
}
`;
export const StyledKey = styled.span<{
$type: TextColorFn["$type"];
$value?: TextColorFn["$value"];
}>`
display: inline;
align-items: center;
justify-content: center;
flex: 1;
min-width: 0;
height: auto;
line-height: inherit;
padding: 0; // Remove padding
color: ${({ theme, $type, $value = "" }) => getTextColor({ $value, $type, theme })};
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
export const StyledRow = styled.span<{ $value: TextColorFn["$value"] }>`
padding: 3px 10px;
height: ${NODE_DIMENSIONS.ROW_HEIGHT}px;
line-height: 24px;
color: ${({ theme, $value }) => getTextColor({ $value, theme, $type: typeof $value })};
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
border-bottom: 1px solid ${({ theme }) => theme.NODE_COLORS.DIVIDER};
box-sizing: border-box;
&:last-of-type {
border-bottom: none;
}
.searched & {
border-bottom: 1px solid ${({ theme }) => theme.TEXT_POSITIVE};
}
`;
export const StyledChildrenCount = styled.span`
color: ${({ theme }) => theme.NODE_COLORS.CHILD_COUNT};
padding: 10px;
margin-left: -15px;
`;
export const StyledEditButton = styled.button`
position: absolute;
top: 4px;
right: 4px;
background: #3B82F6;
border: 1px solid #2563EB;
border-radius: 4px;
padding: 4px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
pointer-events: all;
transition: all 0.2s ease;
color: white;
&:hover {
background: #2563EB;
border-color: #1D4ED8;
}
&:active {
transform: scale(0.95);
}
`;