From fcc535706a3e6331bdce5fe7a313b9e1d9e6809d Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 18 Apr 2023 12:42:13 +0200 Subject: [PATCH] Introduce some `:is` usage in the annotationLayer CSS While this slightly reduces duplication in the CSS rules, some of the auto-formatting done by Prettier is perhaps not great. (Given the overall advantage of using Prettier, we'll probably have to simply accept this.) --- test/annotation_layer_builder_overrides.css | 12 ++--- web/annotation_layer_builder.css | 58 +++++++++------------ 2 files changed, 30 insertions(+), 40 deletions(-) diff --git a/test/annotation_layer_builder_overrides.css b/test/annotation_layer_builder_overrides.css index d28e84628..f882fded4 100644 --- a/test/annotation_layer_builder_overrides.css +++ b/test/annotation_layer_builder_overrides.css @@ -25,26 +25,22 @@ position: absolute; } -.annotationLayer .buttonWidgetAnnotation.checkBox input, -.annotationLayer .buttonWidgetAnnotation.radioButton input { +.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input { -webkit-appearance: none; } -.annotationLayer .linkAnnotation > a, -.annotationLayer .buttonWidgetAnnotation.pushButton > a, +.annotationLayer :is(.linkAnnotation, .buttonWidgetAnnotation.pushButton) > a, .annotationLayer .popupTriggerArea { opacity: 0.2; background: rgba(255, 255, 0, 1); box-shadow: 0 2px 10px rgba(255, 255, 0, 1); } -.annotationLayer .popupAnnotation, -.annotationLayer .popupWrapper { +.annotationLayer :is(.popupAnnotation, .popupWrapper) { display: block; } -.annotationLayer .popup h1, -.annotationLayer .popup p { +.annotationLayer .popup :is(h1, p) { margin: 0; padding: 0; } diff --git a/web/annotation_layer_builder.css b/web/annotation_layer_builder.css index 6a6d95b44..47df4f6b0 100644 --- a/web/annotation_layer_builder.css +++ b/web/annotation_layer_builder.css @@ -31,11 +31,11 @@ --input-hover-border-color: Highlight; --link-outline: 1.5px solid LinkText; } - .annotationLayer .textWidgetAnnotation input:required, - .annotationLayer .textWidgetAnnotation textarea:required, + .annotationLayer .textWidgetAnnotation :is(input, textarea):required, .annotationLayer .choiceWidgetAnnotation select:required, - .annotationLayer .buttonWidgetAnnotation.checkBox input:required, - .annotationLayer .buttonWidgetAnnotation.radioButton input:required { + .annotationLayer + .buttonWidgetAnnotation:is(.checkBox, .radioButton) + input:required { outline: 1.5px solid selectedItem; } @@ -81,8 +81,7 @@ outline: var(--link-outline); } -.annotationLayer .linkAnnotation > a, -.annotationLayer .buttonWidgetAnnotation.pushButton > a { +.annotationLayer :is(.linkAnnotation, .buttonWidgetAnnotation.pushButton) > a { position: absolute; font-size: 1em; top: 0; @@ -91,8 +90,9 @@ height: 100%; } -.annotationLayer .linkAnnotation > a:hover, -.annotationLayer .buttonWidgetAnnotation.pushButton > a:hover { +.annotationLayer + :is(.linkAnnotation, .buttonWidgetAnnotation.pushButton) + > a:hover { opacity: 0.2; background: rgba(255, 255, 0, 1); box-shadow: 0 2px 10px rgba(255, 255, 0, 1); @@ -107,11 +107,9 @@ left: 0; } -.annotationLayer .textWidgetAnnotation input, -.annotationLayer .textWidgetAnnotation textarea, +.annotationLayer .textWidgetAnnotation :is(input, textarea), .annotationLayer .choiceWidgetAnnotation select, -.annotationLayer .buttonWidgetAnnotation.checkBox input, -.annotationLayer .buttonWidgetAnnotation.radioButton input { +.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input { background-image: var(--annotation-unfocused-field-background); border: 2px solid var(--input-unfocused-border-color); box-sizing: border-box; @@ -122,11 +120,11 @@ width: 100%; } -.annotationLayer .textWidgetAnnotation input:required, -.annotationLayer .textWidgetAnnotation textarea:required, +.annotationLayer .textWidgetAnnotation :is(input, textarea):required, .annotationLayer .choiceWidgetAnnotation select:required, -.annotationLayer .buttonWidgetAnnotation.checkBox input:required, -.annotationLayer .buttonWidgetAnnotation.radioButton input:required { +.annotationLayer + .buttonWidgetAnnotation:is(.checkBox, .radioButton) + input:required { outline: 1.5px solid red; } @@ -142,32 +140,30 @@ resize: none; } -.annotationLayer .textWidgetAnnotation input[disabled], -.annotationLayer .textWidgetAnnotation textarea[disabled], +.annotationLayer .textWidgetAnnotation :is(input, textarea)[disabled], .annotationLayer .choiceWidgetAnnotation select[disabled], -.annotationLayer .buttonWidgetAnnotation.checkBox input[disabled], -.annotationLayer .buttonWidgetAnnotation.radioButton input[disabled] { +.annotationLayer + .buttonWidgetAnnotation:is(.checkBox, .radioButton) + input[disabled] { background: none; border: 2px solid var(--input-disabled-border-color); cursor: not-allowed; } -.annotationLayer .textWidgetAnnotation input:hover, -.annotationLayer .textWidgetAnnotation textarea:hover, +.annotationLayer .textWidgetAnnotation :is(input, textarea):hover, .annotationLayer .choiceWidgetAnnotation select:hover, -.annotationLayer .buttonWidgetAnnotation.checkBox input:hover, -.annotationLayer .buttonWidgetAnnotation.radioButton input:hover { +.annotationLayer + .buttonWidgetAnnotation:is(.checkBox, .radioButton) + input:hover { border: 2px solid var(--input-hover-border-color); } -.annotationLayer .textWidgetAnnotation input:hover, -.annotationLayer .textWidgetAnnotation textarea:hover, +.annotationLayer .textWidgetAnnotation :is(input, textarea):hover, .annotationLayer .choiceWidgetAnnotation select:hover, .annotationLayer .buttonWidgetAnnotation.checkBox input:hover { border-radius: 2px; } -.annotationLayer .textWidgetAnnotation input:focus, -.annotationLayer .textWidgetAnnotation textarea:focus, +.annotationLayer .textWidgetAnnotation :is(input, textarea):focus, .annotationLayer .choiceWidgetAnnotation select:focus { background: none; border: 2px solid var(--input-focus-border-color); @@ -175,8 +171,7 @@ outline: var(--input-focus-outline); } -.annotationLayer .buttonWidgetAnnotation.checkBox :focus, -.annotationLayer .buttonWidgetAnnotation.radioButton :focus { +.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) :focus { background-image: none; background-color: transparent; } @@ -240,8 +235,7 @@ width: 103%; } -.annotationLayer .buttonWidgetAnnotation.checkBox input, -.annotationLayer .buttonWidgetAnnotation.radioButton input { +.annotationLayer .buttonWidgetAnnotation:is(.checkBox, .radioButton) input { appearance: none; }