Skip to content

Commit 7ee64f6

Browse files
committed
色廃止 線だけ
1 parent 71f4089 commit 7ee64f6

File tree

3 files changed

+39
-45
lines changed

3 files changed

+39
-45
lines changed

js/scrapboxCssScript.js

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,25 +64,18 @@ const insertIndentCSSRule = (scrapboxIndentOptions) => {
6464
});
6565
};
6666

67-
const indentColorCSS = [
67+
const indentLineCSS = [
6868
`.app:not(.presentation) .indent-mark .char-index:not(:nth-last-child(1)):not(:nth-last-child(2)) { position: relative; }`,
6969
`.app:not(.presentation) .indent-mark .char-index:not(:nth-last-child(1)):not(:nth-last-child(2))::before {
7070
content: " ";
7171
position: absolute;
72-
left: 44%;
72+
left: 43%;
73+
margin: -4px 0;
7374
border-left: 2px solid #dcdcdc;
74-
z-index: 999;
75-
}`,
76-
`.app:not(.presentation) .indent-mark .char-index:not(:nth-last-child(1)):not(:nth-last-child(2))::after {
77-
background-color: #f5f5f5;
78-
content: " ";
79-
width: 24px;
80-
left: 0;
81-
position: absolute;
8275
}`,
8376
];
8477

85-
const insertIndentColorCSSRule = (isColoring) => {
78+
const insertIndentLineCSSRule = (isLining) => {
8679
// delete existing rules
8780
const cssRules = document.styleSheets[0].cssRules;
8881
const cssRulesNum = cssRules.length;
@@ -102,8 +95,8 @@ const insertIndentColorCSSRule = (isColoring) => {
10295
}
10396

10497
// insert new rules
105-
if (isColoring) {
106-
indentColorCSS.map((css) => {
98+
if (isLining) {
99+
indentLineCSS.map((css) => {
107100
document.styleSheets[0].insertRule(css);
108101
});
109102
}
@@ -116,10 +109,10 @@ const makerAttachment = () => {
116109
});
117110
};
118111

119-
const coloringAttachment = () => {
120-
chrome.storage.local.get('scrapboxIndentColoring', (result) => {
121-
const isColoring = result.scrapboxIndentColoring;
122-
insertIndentColorCSSRule(isColoring);
112+
const liningAttachment = () => {
113+
chrome.storage.local.get('scrapboxIndentLining', (result) => {
114+
const isLining = result.scrapboxIndentLining;
115+
insertIndentLineCSSRule(isLining);
123116
});
124117
};
125118

@@ -128,11 +121,11 @@ chrome.runtime.onMessage.addListener((request) => {
128121
if (request === 'scrapbox_list_maker') {
129122
makerAttachment();
130123
}
131-
if (request === 'scrapbox_indent_coloring') {
132-
coloringAttachment();
124+
if (request === 'scrapbox_indent_lining') {
125+
liningAttachment();
133126
}
134127
});
135128

136129
// initialize
137130
makerAttachment();
138-
coloringAttachment();
131+
liningAttachment();

src/components/Console.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type Props = Record<string, never>;
2424
export const Console: React.FC<Props> = () => {
2525
const [indentOptions, setIndentOptions] =
2626
useState<IndentOptionsType>(initialState);
27-
const [indentColoring, setIndentColoring] = useState<boolean>(false);
27+
const [indentLining, setIndentLining] = useState<boolean>(false);
2828

2929
useEffect(() => {
3030
chrome.storage.local.get('scrapboxIndentOption', (result) => {
@@ -38,28 +38,28 @@ export const Console: React.FC<Props> = () => {
3838
}
3939
});
4040

41-
chrome.storage.local.get('scrapboxIndentColoring', (result) => {
42-
const scrapboxIndentColoring = result.scrapboxIndentColoring;
41+
chrome.storage.local.get('scrapboxIndentLining', (result) => {
42+
const scrapboxIndentLining = result.scrapboxIndentLining;
4343

44-
if (!scrapboxIndentColoring) {
45-
chrome.storage.local.set({ scrapboxIndentColoring: false });
46-
setIndentColoring(false);
44+
if (!scrapboxIndentLining) {
45+
chrome.storage.local.set({ scrapboxIndentLining: false });
46+
setIndentLining(false);
4747
} else {
48-
setIndentColoring(scrapboxIndentColoring);
48+
setIndentLining(scrapboxIndentLining);
4949
}
5050
});
5151
}, []);
5252

53-
const handleIndentColoringChange = (checked: boolean) => {
54-
chrome.storage.local.set({ scrapboxIndentColoring: checked });
55-
setIndentColoring(checked);
53+
const handleIndentLiningChange = (checked: boolean) => {
54+
chrome.storage.local.set({ scrapboxIndentLining: checked });
55+
setIndentLining(checked);
5656

5757
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
5858
tabs.forEach((tab) => {
5959
if (tab.url === undefined || tab.id === undefined) return;
6060
const url = new URL(tab.url);
6161
if (url.hostname === 'scrapbox.io') {
62-
chrome.tabs.sendMessage(tab.id, 'scrapbox_indent_coloring');
62+
chrome.tabs.sendMessage(tab.id, 'scrapbox_indent_lining');
6363
}
6464
});
6565
});
@@ -107,8 +107,8 @@ export const Console: React.FC<Props> = () => {
107107
<Title>Select Favorite List Maker</Title>
108108
<SwitchLabel>
109109
<Switch
110-
checked={indentColoring}
111-
onChange={handleIndentColoringChange}
110+
checked={indentLining}
111+
onChange={handleIndentLiningChange}
112112
onColor="#00b428"
113113
boxShadow="0px 1px 5px rgba(0, 0, 0, 0.6)"
114114
height={16}
@@ -144,7 +144,7 @@ export const Console: React.FC<Props> = () => {
144144
);
145145
})}
146146
</IndentContainer>
147-
<Demonstration isGrey={indentColoring} indentOptions={indentOptions} />
147+
<Demonstration hasLine={indentLining} indentOptions={indentOptions} />
148148
</MainContainer>
149149
);
150150
};

src/components/Demonstration.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import styled from 'styled-components';
33
import { IndentOptionsType } from '../utils/types';
44

55
type Props = {
6-
isGrey: boolean;
6+
hasLine: boolean;
77
indentOptions: IndentOptionsType;
88
};
99

@@ -21,8 +21,8 @@ export const Demonstration: React.FC<Props> = (props) => {
2121
{[...Array(spaceNum)].map((j) => {
2222
return (
2323
<VerticalLineIndentContainer key={j}>
24-
{props.isGrey && <VerticalLine />}
25-
<Indent isGrey={props.isGrey} />
24+
{props.hasLine && <VerticalLine />}
25+
<Indent hasLine={props.hasLine} />
2626
</VerticalLineIndentContainer>
2727
);
2828
})}
@@ -75,18 +75,17 @@ const VerticalLineIndentContainer = styled.div`
7575
`;
7676

7777
const VerticalLine = styled.div`
78-
width: 0.2px;
79-
height: 27px;
78+
width: 1px;
79+
height: 23px;
8080
position: absolute;
81-
top: -40%;
82-
left: 50%;
81+
top: 0;
82+
left: 45%;
8383
background-color: #dcdcdc;
8484
`;
8585

86-
const Indent = styled.div<{ isGrey: boolean }>`
86+
const Indent = styled.div<{ hasLine: boolean }>`
8787
width: 24px;
88-
height: 15px;
89-
background-color: ${(props) => (props.isGrey ? '#f5f5f5' : '#fff')};
88+
height: 23px;
9089
`;
9190

9291
const IndentContent = styled.div`
@@ -99,7 +98,9 @@ const IndentContent = styled.div`
9998

10099
const IndentValue = styled.span`
101100
font-size: 10px;
102-
transform: scale(0.8);
101+
transform: scale(0.75);
102+
font-weight: bold;
103+
color: rgba(0, 0, 0, 0.65);
103104
`;
104105

105106
const IndentOption = styled.span`

0 commit comments

Comments
 (0)