77 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-09-13 21:39:58 +05:30
import { darken, lighten, isDark } from 'khroma';
2022-07-27 09:43:25 +02:00
2022-07-25 17:03:18 +02:00
const genSections = (options) => {
let sections = '';
2022-07-27 09:43:25 +02:00
for (let i = 0; i < 8; i++) {
2022-08-30 21:37:26 +02:00
options['lineColor' + i] = options['lineColor' + i] || options['gitInv' + i];
2022-07-27 09:43:25 +02:00
if (isDark(options['lineColor' + i])) {
2022-07-27 10:24:27 +02:00
options['lineColor' + i] = lighten(options['lineColor' + i], 20);
2022-07-27 09:43:25 +02:00
} else {
2022-07-27 10:24:27 +02:00
options['lineColor' + i] = darken(options['lineColor' + i], 20);
2022-07-27 09:43:25 +02:00
}
}
for (let i = 0; i < 8; i++) {
2022-07-25 17:03:18 +02:00
const sw = '' + (17 - 3 * i);
sections += `
2022-09-05 09:53:04 +02:00
.section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${
i - 1
} path {
2022-07-25 17:03:18 +02:00
fill: ${options['git' + i]};
}
.section-${i - 1} text {
fill: ${options['gitBranchLabel' + i]};
2022-08-30 21:37:26 +02:00
// fill: ${options['gitInv' + i]};
2022-07-25 17:03:18 +02:00
}
2022-07-27 18:40:44 +02:00
.node-icon-${i - 1} {
font-size: 40px;
color: ${options['gitBranchLabel' + i]};
2022-08-30 21:37:26 +02:00
// color: ${options['gitInv' + i]};
2022-07-27 18:40:44 +02:00
}
2022-07-25 17:03:18 +02:00
.section-edge-${i - 1}{
stroke: ${options['git' + i]};
}
.edge-depth-${i - 1}{
stroke-width: ${sw};
}
2022-07-27 09:43:25 +02:00
.section-${i - 1} line {
stroke: ${options['lineColor' + i]} ;
stroke-width: 3;
}
.disabled, .disabled circle, .disabled text {
fill: lightgray;
}
.disabled text {
fill: #efefef;
}
2022-07-25 17:03:18 +02:00
`;
}
return sections;
};
const getStyles = (options) =>
`
2022-07-25 17:03:18 +02:00
.edge {
stroke-width: 3;
}
${genSections(options)}
2022-07-29 15:06:21 +02:00
.section-root rect, .section-root path, .section-root circle {
2022-07-25 17:03:18 +02:00
fill: ${options.git0};
}
.section-root text {
fill: ${options.gitBranchLabel0};
}
2022-07-27 18:40:44 +02:00
.icon-container {
height:100%;
display: flex;
justify-content: center;
2022-07-27 19:10:06 +02:00
align-items: center;
2022-07-27 18:40:44 +02:00
}
2022-07-29 15:06:21 +02:00
.edge {
fill: none;
}
`;
2022-07-18 16:00:03 +02:00
export default getStyles;