Skip to content

Commit

Permalink
Add camelCase CSS naming rules
Browse files Browse the repository at this point in the history
  • Loading branch information
julieg18 committed Jun 21, 2023
1 parent 48ed9c4 commit 857b7e6
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 83 deletions.
16 changes: 14 additions & 2 deletions webview/.stylelintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,20 @@ module.exports = {
true,
{ ignorePseudoClasses: ['global'] }
],
'custom-property-pattern': null,
'selector-class-pattern': null,
'custom-property-pattern': [
'^[a-z][a-zA-Z0-9]+$',
{
message: selector =>
`Expected custom property name "${selector}" to be camelCase`
}
],
'selector-class-pattern': [
'^[a-z][a-zA-Z0-9]+$',
{
message: selector =>
`Expected class selector "${selector}" to be camelCase`
}
],
'scss/percent-placeholder-pattern': null,
'scss/dollar-variable-empty-line-before': [
'always',
Expand Down
2 changes: 1 addition & 1 deletion webview/src/plots/components/ZoomedInPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ZoomedInPlot: React.FC<ZoomedInPlotProps> = ({
props
}: ZoomedInPlotProps) => {
useEffect(() => {
const modalOpenClass = 'modal-open'
const modalOpenClass = 'modalOpen'
document.body.classList.add(modalOpenClass)

return () => {
Expand Down
145 changes: 75 additions & 70 deletions webview/src/plots/components/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,6 @@ $gap: 20px;
width: 100%;
}

:global(.vega-bindings):not(:empty) {
position: absolute;
bottom: 0;
width: 100%;
background-color: $plot-block-bg-color;
color: $fg-color;
padding: 10px;
display: none;

label {
display: flex;
align-items: center;
justify-content: center;
}

input {
accent-color: $accent-color;
outline: none;
}
}

:global(.vega-embed) {
width: 100%;
height: 100%;
align-self: center;
display: flex !important;
align-items: center;
justify-content: center;

&:hover {
:global(.vega-bindings) {
display: block;
}
}

svg {
overflow: visible;
}
}

.singleViewPlotsGrid,
.multiViewPlotsGrid {
width: 100%;
Expand All @@ -63,31 +23,6 @@ $gap: 20px;
}
}

:global(.ReactVirtualized__Grid__innerScrollContainer),
.noBigGrid {
width: calc(100% - $gap * 2) !important;
max-width: none !important;
max-height: none !important;
height: auto !important;
margin-left: $gap;
display: grid;
gap: $gap;
grid-auto-flow: row;
grid-template-columns: repeat(var(--nbPerRow), 1fr);

+ .singleViewPlotsGrid,
+ .multiViewPlotsGrid {
margin-top: $gap;
}

// When editing the grid-template-column for any viewport or plot size, `getNbItemsPerRow` in the `./utils.ts` file should also be updated
.smallPlots & {
:global(.role-axis-title) text {
font-size: 10px;
}
}
}

.plot {
overflow: visible;
cursor: grab;
Expand Down Expand Up @@ -222,11 +157,6 @@ $gap: 20px;
width: 80vw;
height: calc(80vh - 100px);

:global(.chart-wrapper) {
width: 100%;
height: 100%;
}

svg {
background-color: transparent !important;
width: 100%;
Expand All @@ -249,6 +179,78 @@ $gap: 20px;
display: flex;
}

/* stylelint-disable custom-property-pattern, selector-class-pattern -- 3rd party selectors */

:global(.vega-bindings):not(:empty) {
position: absolute;
bottom: 0;
width: 100%;
background-color: $plot-block-bg-color;
color: $fg-color;
padding: 10px;
display: none;

label {
display: flex;
align-items: center;
justify-content: center;
}

input {
accent-color: $accent-color;
outline: none;
}
}

:global(.vega-embed) {
width: 100%;
height: 100%;
align-self: center;
display: flex !important;
align-items: center;
justify-content: center;

&:hover {
:global(.vega-bindings) {
display: block;
}
}

svg {
overflow: visible;
}
}

.zoomedInPlot :global(.chart-wrapper) {
width: 100%;
height: 100%;
}

:global(.ReactVirtualized__Grid__innerScrollContainer),
.noBigGrid {
width: calc(100% - $gap * 2) !important;
max-width: none !important;
max-height: none !important;
height: auto !important;
margin-left: $gap;
display: grid;
gap: $gap;
grid-auto-flow: row;
grid-template-columns: repeat(var(--nbPerRow), 1fr);

+ .singleViewPlotsGrid,
+ .multiViewPlotsGrid {
margin-top: $gap;
}

// When editing the grid-template-column for any viewport or plot size, `getNbItemsPerRow` in the `./utils.ts` file should also be updated
.smallPlots & {
:global(.role-axis-title) text {
font-size: 10px;
}
}
}

:global(.has-actions) {
summary {
background: $fg-color !important;
Expand All @@ -264,6 +266,9 @@ $gap: 20px;
}

a:hover {
/* TBD this variable needs updating */
background-color: var(--editor-background-transparency-1) !important;
}
}

/* stylelint-enable custom-property-pattern, selector-class-pattern */
9 changes: 3 additions & 6 deletions webview/src/shared/mixins.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
%link {
color: var(--vscode-textLink-foreground);

&:hover {
color: var(--vscode-textLink-activeForeground);
}
color: $link-fg-color;

&:hover,
&:active {
color: var(--vscode-textLink-activeForeground);
color: $link-active-color;
}
}

Expand Down
9 changes: 5 additions & 4 deletions webview/src/shared/styles.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import './variables';
@import './mixins';

* {
Expand All @@ -22,12 +23,12 @@ body {
border: 0;
margin: 0;
padding: 0;
background-color: var(--vscode-editor-background);
color: var(--vscode-editor-foreground);
font-family: var(--vscode-editor-font-family);
background-color: $bg-color;
color: $fg-color;
font-family: $font;
}

.modal-open {
.modalOpen {
overflow: hidden;
}

Expand Down
5 changes: 5 additions & 0 deletions webview/src/shared/variables.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* stylelint-disable custom-property-pattern -- VSCode variables are not camelCase */

/* common */
$bullet-size: 9px;
$tooltip-border: var(--vscode-editorHoverWidget-border);
$hover-background-color: var(--vscode-list-hoverBackground);
$shadow: var(--vscode-widget-shadow);
$font: var(--vscode-editor-font-family);

/* common colors */
$fg-color: var(--vscode-editor-foreground);
Expand All @@ -20,6 +23,8 @@ $accent-color: var(--button-primary-background);
$accent-color-transparent: var(--accent-transparency-3);
$passed-color: var(--vscode-testing-iconPassed);
$description-color: var(--vscode-descriptionForeground);
$link-fg-color: var(--vscode-textLink-foreground);
$link-active-color: var(--vscode-textLink-activeForeground);

/* experiments table */
$row-bg-color: $bg-color;
Expand Down

0 comments on commit 857b7e6

Please sign in to comment.