digirati-co-uk / iiif-canvas-panel

Investigation into component granularity
https://iiif-canvas-panel.netlify.app/
MIT License
9 stars 6 forks source link

Annotation Styling #93

Closed tomcrane closed 7 months ago

tomcrane commented 2 years ago

"Draw a box" - but not the user drawing a box (that come later!)

This issue is supporting the features described here: https://deploy-preview-50--iiif-canvas-panel.netlify.app/docs/examples/drawing-boxes/

CP showing a region is covered by #69

This is making a visible change. Via attributes:

<canvas-panel
   iiif-content=https://data.ng-london.org.uk/iiif/0CWR-0001-0000-0000/canvas/-1
   partof=https://data.ng-london.org.uk/iiif/0CWR-0001-0000-0000/manifest
   region="2000,2000,1000,1000"
   highlight="2400,2400,400,400"
   highlight-css-class="red-box"
/>

In code, this reveals dependencies on two other features, Target and DisplayAnnotation as wrapper. These features are still under discussion. (https://github.com/digirati-co-uk/iiif-canvas-panel/discussions/33)

<canvas-panel id="cp"></canvas-panel>
<script>
   const vault = new Vault();
   const cp = document.getElementById("cp");
   await vault.loadManifest("..manifest_id..");
   cp.setCanvas("..canvas_id..");

   // set the viewport to a region:
   // With no additional arguments, there is no animation
   cp.goToTarget(new Target("xywh=2000,2000,1000,1000"));

   // draw a box in this region (the verbose way, for comparison, but could be short form):
   const redBoxTarget = new Target();
   redBoxTarget.spatial.x = 2400;
   redBoxTarget.spatial.y = 2400;
   redBoxTarget.spatial.w = 400;
   redBoxTarget.spatial.h = 400;

   // create an annotation with motivation "highlighting"
   const anno = new HighlightingAnnotation();
   anno.target = redBoxTarget;

  // here I could ask for anno.toW3CAnno() and get a pure W3C JSON

   // create anno in vault
   vault.load("my-anno", anno);

   const displayAnno = new DisplayAnnotation(vault.FromRef("my-anno"));
   displayAnno.cssClass = "red-box";

   cp.DisplayAnnotations.add(displayAnno);

   // could go-native here with 
   // cp.worldObject.appendChild( ... );

</script> 
tomcrane commented 2 years ago

In summary - make https://iiif-canvas-panel.netlify.app/docs/examples/drawing-boxes/ work!

tomcrane commented 2 years ago

What CSS can be applied to a DisplayAnnotation?

This is not for painting annotations. This is for all other annotations whose presence on

The fact that these annos are not painting means that it's OK for CP to have limits to how they are displayed - we're activating a display "mode" for what's really a piece of data.

Often the only thing CP will be doing is highlighting a box and responding to pointer or selection events on that box, because the actual content of the anno will be dealt with outside of Canvas Panel, or superimposed on top of it - e.g., Ocean Liners text and image content (is that right? Is CP being asked to display this? Or is it the Ocean Liners app?)

There's the style applied directly to the displayAnnotation's corresponding DIV element, and then there's styles for content within it. E.g., how would you specify what links should like with an annotation whose body is text/html?

There's also the marker for point annotations - e.g., Ocean Liners again - does CP show the map marker / button? Or the app built on top of it?

For consideration - [ ] [accent-color](https://developer.mozilla.org/en-US/docs/Web/CSS/accent-color) - [ ] [align-content](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) - [ ] [align-items](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) - [ ] [align-self](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self) - [ ] [alignment-baseline](https://developer.mozilla.org/en-US/docs/Web/CSS/alignment-baseline) - [ ] [animation-delay](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-delay) - [ ] [animation-direction](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-direction) - [ ] [animation-duration](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-duration) - [ ] [animation-fill-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-fill-mode) - [ ] [animation-iteration-count](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-iteration-count) - [ ] [animation-name](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-name) - [ ] [animation-play-state](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-play-state) - [ ] [animation-timing-function](https://developer.mozilla.org/en-US/docs/Web/CSS/animation-timing-function) - [ ] [app-region](https://developer.mozilla.org/en-US/docs/Web/CSS/app-region) - [ ] [appearance](https://developer.mozilla.org/en-US/docs/Web/CSS/appearance) - [ ] [backdrop-filter](https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter) - [ ] [backface-visibility](https://developer.mozilla.org/en-US/docs/Web/CSS/backface-visibility) - [ ] [background-attachment](https://developer.mozilla.org/en-US/docs/Web/CSS/background-attachment) - [ ] [background-blend-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/background-blend-mode) - [ ] [background-clip](https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip) - [x] [background-color](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color) - [ ] [background-image](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image) - [ ] [background-origin](https://developer.mozilla.org/en-US/docs/Web/CSS/background-origin) - [ ] [background-position](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) - [ ] [background-repeat](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat) - [ ] [background-size](https://developer.mozilla.org/en-US/docs/Web/CSS/background-size) - [ ] [baseline-shift](https://developer.mozilla.org/en-US/docs/Web/CSS/baseline-shift) - [ ] [block-size](https://developer.mozilla.org/en-US/docs/Web/CSS/block-size) - [ ] [border-block-end-color](https://developer.mozilla.org/en-US/docs/Web/CSS/border-block-end-color) - [ ] [border-block-end-style](https://developer.mozilla.org/en-US/docs/Web/CSS/border-block-end-style) - [ ] [border-block-end-width](https://developer.mozilla.org/en-US/docs/Web/CSS/border-block-end-width) - [ ] [border-block-start-color](https://developer.mozilla.org/en-US/docs/Web/CSS/border-block-start-color) - [ ] [border-block-start-style](https://developer.mozilla.org/en-US/docs/Web/CSS/border-block-start-style) - [ ] [border-block-start-width](https://developer.mozilla.org/en-US/docs/Web/CSS/border-block-start-width) - [ ] [border-bottom-color](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-color) - [ ] [border-bottom-left-radius](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-left-radius) - [ ] [border-bottom-right-radius](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-right-radius) - [ ] [border-bottom-style](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-style) - [ ] [border-bottom-width](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-width) - [ ] [border-collapse](https://developer.mozilla.org/en-US/docs/Web/CSS/border-collapse) - [ ] [border-end-end-radius](https://developer.mozilla.org/en-US/docs/Web/CSS/border-end-end-radius) - [ ] [border-end-start-radius](https://developer.mozilla.org/en-US/docs/Web/CSS/border-end-start-radius) - [ ] [border-image-outset](https://developer.mozilla.org/en-US/docs/Web/CSS/border-image-outset) - [ ] [border-image-repeat](https://developer.mozilla.org/en-US/docs/Web/CSS/border-image-repeat) - [ ] [border-image-slice](https://developer.mozilla.org/en-US/docs/Web/CSS/border-image-slice) - [ ] [border-image-source](https://developer.mozilla.org/en-US/docs/Web/CSS/border-image-source) - [ ] [border-image-width](https://developer.mozilla.org/en-US/docs/Web/CSS/border-image-width) - [ ] [border-inline-end-color](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-end-color) - [ ] [border-inline-end-style](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-end-style) - [ ] [border-inline-end-width](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-end-width) - [ ] [border-inline-start-color](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-start-color) - [ ] [border-inline-start-style](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-start-style) - [ ] [border-inline-start-width](https://developer.mozilla.org/en-US/docs/Web/CSS/border-inline-start-width) - [ ] [border-left-color](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-color) - [ ] [border-left-style](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-style) - [ ] [border-left-width](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-width) - [ ] [border-right-color](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right-color) - [ ] [border-right-style](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right-style) - [ ] [border-right-width](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right-width) - [ ] [border-start-end-radius](https://developer.mozilla.org/en-US/docs/Web/CSS/border-start-end-radius) - [ ] [border-start-start-radius](https://developer.mozilla.org/en-US/docs/Web/CSS/border-start-start-radius) - [ ] [border-top-color](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-color) - [ ] [border-top-left-radius](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-left-radius) - [ ] [border-top-right-radius](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-right-radius) - [ ] [border-top-style](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-style) - [ ] [border-top-width](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-width) - [ ] [bottom](https://developer.mozilla.org/en-US/docs/Web/CSS/bottom) - [x] [box-shadow](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow) - [ ] [box-sizing](https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing) - [ ] [break-after](https://developer.mozilla.org/en-US/docs/Web/CSS/break-after) - [ ] [break-before](https://developer.mozilla.org/en-US/docs/Web/CSS/break-before) - [ ] [break-inside](https://developer.mozilla.org/en-US/docs/Web/CSS/break-inside) - [ ] [buffered-rendering](https://developer.mozilla.org/en-US/docs/Web/CSS/buffered-rendering) - [ ] [caption-side](https://developer.mozilla.org/en-US/docs/Web/CSS/caption-side) - [ ] [caret-color](https://developer.mozilla.org/en-US/docs/Web/CSS/caret-color) - [ ] [clear](https://developer.mozilla.org/en-US/docs/Web/CSS/clear) - [ ] [clip](https://developer.mozilla.org/en-US/docs/Web/CSS/clip) - [ ] [clip-path](https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path) - [ ] [clip-rule](https://developer.mozilla.org/en-US/docs/Web/CSS/clip-rule) - [ ] [color](https://developer.mozilla.org/en-US/docs/Web/CSS/color) - [ ] [color-interpolation](https://developer.mozilla.org/en-US/docs/Web/CSS/color-interpolation) - [ ] [color-interpolation-filters](https://developer.mozilla.org/en-US/docs/Web/CSS/color-interpolation-filters) - [ ] [color-rendering](https://developer.mozilla.org/en-US/docs/Web/CSS/color-rendering) - [ ] [column-count](https://developer.mozilla.org/en-US/docs/Web/CSS/column-count) - [ ] [column-gap](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) - [ ] [column-rule-color](https://developer.mozilla.org/en-US/docs/Web/CSS/column-rule-color) - [ ] [column-rule-style](https://developer.mozilla.org/en-US/docs/Web/CSS/column-rule-style) - [ ] [column-rule-width](https://developer.mozilla.org/en-US/docs/Web/CSS/column-rule-width) - [ ] [column-span](https://developer.mozilla.org/en-US/docs/Web/CSS/column-span) - [ ] [column-width](https://developer.mozilla.org/en-US/docs/Web/CSS/column-width) - [ ] [contain-intrinsic-block-size](https://developer.mozilla.org/en-US/docs/Web/CSS/contain-intrinsic-block-size) - [ ] [contain-intrinsic-height](https://developer.mozilla.org/en-US/docs/Web/CSS/contain-intrinsic-height) - [ ] [contain-intrinsic-inline-size](https://developer.mozilla.org/en-US/docs/Web/CSS/contain-intrinsic-inline-size) - [ ] [contain-intrinsic-size](https://developer.mozilla.org/en-US/docs/Web/CSS/contain-intrinsic-size) - [ ] [contain-intrinsic-width](https://developer.mozilla.org/en-US/docs/Web/CSS/contain-intrinsic-width) - [ ] [content](https://developer.mozilla.org/en-US/docs/Web/CSS/content) - [ ] [cursor](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor) - [ ] [cx](https://developer.mozilla.org/en-US/docs/Web/CSS/cx) - [ ] [cy](https://developer.mozilla.org/en-US/docs/Web/CSS/cy) - [ ] [d](https://developer.mozilla.org/en-US/docs/Web/CSS/d) - [ ] [direction](https://developer.mozilla.org/en-US/docs/Web/CSS/direction) - [ ] [display](https://developer.mozilla.org/en-US/docs/Web/CSS/display) - [ ] [dominant-baseline](https://developer.mozilla.org/en-US/docs/Web/CSS/dominant-baseline) - [ ] [empty-cells](https://developer.mozilla.org/en-US/docs/Web/CSS/empty-cells) - [ ] [fill](https://developer.mozilla.org/en-US/docs/Web/CSS/fill) - [ ] [fill-opacity](https://developer.mozilla.org/en-US/docs/Web/CSS/fill-opacity) - [ ] [fill-rule](https://developer.mozilla.org/en-US/docs/Web/CSS/fill-rule) - [ ] [filter](https://developer.mozilla.org/en-US/docs/Web/CSS/filter) - [ ] [flex-basis](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis) - [ ] [flex-direction](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction) - [ ] [flex-grow](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-grow) - [ ] [flex-shrink](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-shrink) - [ ] [flex-wrap](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap) - [ ] [float](https://developer.mozilla.org/en-US/docs/Web/CSS/float) - [ ] [flood-color](https://developer.mozilla.org/en-US/docs/Web/CSS/flood-color) - [ ] [flood-opacity](https://developer.mozilla.org/en-US/docs/Web/CSS/flood-opacity) - [ ] [font-family](https://developer.mozilla.org/en-US/docs/Web/CSS/font-family) - [ ] [font-kerning](https://developer.mozilla.org/en-US/docs/Web/CSS/font-kerning) - [ ] [font-optical-sizing](https://developer.mozilla.org/en-US/docs/Web/CSS/font-optical-sizing) - [ ] [font-size](https://developer.mozilla.org/en-US/docs/Web/CSS/font-size) - [ ] [font-stretch](https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch) - [ ] [font-style](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style) - [ ] [font-synthesis-small-caps](https://developer.mozilla.org/en-US/docs/Web/CSS/font-synthesis-small-caps) - [ ] [font-synthesis-style](https://developer.mozilla.org/en-US/docs/Web/CSS/font-synthesis-style) - [ ] [font-synthesis-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-synthesis-weight) - [ ] [font-variant](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant) - [ ] [font-variant-caps](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-caps) - [ ] [font-variant-east-asian](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-east-asian) - [ ] [font-variant-ligatures](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-ligatures) - [ ] [font-variant-numeric](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-numeric) - [ ] [font-weight](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) - [ ] [grid-auto-columns](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns) - [ ] [grid-auto-flow](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) - [ ] [grid-auto-rows](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows) - [ ] [grid-column-end](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-end) - [ ] [grid-column-start](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column-start) - [ ] [grid-row-end](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-end) - [ ] [grid-row-start](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row-start) - [ ] [grid-template-areas](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas) - [ ] [grid-template-columns](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns) - [ ] [grid-template-rows](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows) - [ ] [height](https://developer.mozilla.org/en-US/docs/Web/CSS/height) - [ ] [hyphens](https://developer.mozilla.org/en-US/docs/Web/CSS/hyphens) - [ ] [image-orientation](https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation) - [ ] [image-rendering](https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering) - [ ] [inline-size](https://developer.mozilla.org/en-US/docs/Web/CSS/inline-size) - [ ] [inset-block-end](https://developer.mozilla.org/en-US/docs/Web/CSS/inset-block-end) - [ ] [inset-block-start](https://developer.mozilla.org/en-US/docs/Web/CSS/inset-block-start) - [ ] [inset-inline-end](https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-end) - [ ] [inset-inline-start](https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-start) - [ ] [isolation](https://developer.mozilla.org/en-US/docs/Web/CSS/isolation) - [ ] [justify-content](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) - [ ] [justify-items](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) - [ ] [justify-self](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self) - [ ] [left](https://developer.mozilla.org/en-US/docs/Web/CSS/left) - [ ] [letter-spacing](https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing) - [ ] [lighting-color](https://developer.mozilla.org/en-US/docs/Web/CSS/lighting-color) - [ ] [line-break](https://developer.mozilla.org/en-US/docs/Web/CSS/line-break) - [ ] [line-height](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height) - [ ] [list-style-image](https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-image) - [ ] [list-style-position](https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-position) - [ ] [list-style-type](https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-type) - [ ] [margin-block-end](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-block-end) - [ ] [margin-block-start](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-block-start) - [ ] [margin-bottom](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-bottom) - [ ] [margin-inline-end](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-end) - [ ] [margin-inline-start](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-start) - [ ] [margin-left](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-left) - [ ] [margin-right](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-right) - [ ] [margin-top](https://developer.mozilla.org/en-US/docs/Web/CSS/margin-top) - [ ] [marker-end](https://developer.mozilla.org/en-US/docs/Web/CSS/marker-end) - [ ] [marker-mid](https://developer.mozilla.org/en-US/docs/Web/CSS/marker-mid) - [ ] [marker-start](https://developer.mozilla.org/en-US/docs/Web/CSS/marker-start) - [ ] [mask-type](https://developer.mozilla.org/en-US/docs/Web/CSS/mask-type) - [ ] [max-block-size](https://developer.mozilla.org/en-US/docs/Web/CSS/max-block-size) - [ ] [max-height](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height) - [ ] [max-inline-size](https://developer.mozilla.org/en-US/docs/Web/CSS/max-inline-size) - [ ] [max-width](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width) - [ ] [min-block-size](https://developer.mozilla.org/en-US/docs/Web/CSS/min-block-size) - [ ] [min-height](https://developer.mozilla.org/en-US/docs/Web/CSS/min-height) - [ ] [min-inline-size](https://developer.mozilla.org/en-US/docs/Web/CSS/min-inline-size) - [ ] [min-width](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width) - [ ] [mix-blend-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-mode) - [ ] [object-fit](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) - [ ] [object-position](https://developer.mozilla.org/en-US/docs/Web/CSS/object-position) - [ ] [offset-distance](https://developer.mozilla.org/en-US/docs/Web/CSS/offset-distance) - [ ] [offset-path](https://developer.mozilla.org/en-US/docs/Web/CSS/offset-path) - [ ] [offset-rotate](https://developer.mozilla.org/en-US/docs/Web/CSS/offset-rotate) - [x] [opacity](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity) - [ ] [order](https://developer.mozilla.org/en-US/docs/Web/CSS/order) - [ ] [orphans](https://developer.mozilla.org/en-US/docs/Web/CSS/orphans) - [x] [outline-color](https://developer.mozilla.org/en-US/docs/Web/CSS/outline-color) - [x] [outline-offset](https://developer.mozilla.org/en-US/docs/Web/CSS/outline-offset) - [ ] [outline-style](https://developer.mozilla.org/en-US/docs/Web/CSS/outline-style) - [x] [outline-width](https://developer.mozilla.org/en-US/docs/Web/CSS/outline-width) - [ ] [overflow-anchor](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-anchor) - [ ] [overflow-clip-margin](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-margin) - [ ] [overflow-wrap](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap) - [ ] [overflow-x](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-x) - [ ] [overflow-y](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-y) - [ ] [overscroll-behavior-block](https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior-block) - [ ] [overscroll-behavior-inline](https://developer.mozilla.org/en-US/docs/Web/CSS/overscroll-behavior-inline) - [ ] [padding-block-end](https://developer.mozilla.org/en-US/docs/Web/CSS/padding-block-end) - [ ] [padding-block-start](https://developer.mozilla.org/en-US/docs/Web/CSS/padding-block-start) - [ ] [padding-bottom](https://developer.mozilla.org/en-US/docs/Web/CSS/padding-bottom) - [ ] [padding-inline-end](https://developer.mozilla.org/en-US/docs/Web/CSS/padding-inline-end) - [ ] [padding-inline-start](https://developer.mozilla.org/en-US/docs/Web/CSS/padding-inline-start) - [ ] [padding-left](https://developer.mozilla.org/en-US/docs/Web/CSS/padding-left) - [ ] [padding-right](https://developer.mozilla.org/en-US/docs/Web/CSS/padding-right) - [ ] [padding-top](https://developer.mozilla.org/en-US/docs/Web/CSS/padding-top) - [ ] [paint-order](https://developer.mozilla.org/en-US/docs/Web/CSS/paint-order) - [ ] [perspective](https://developer.mozilla.org/en-US/docs/Web/CSS/perspective) - [ ] [perspective-origin](https://developer.mozilla.org/en-US/docs/Web/CSS/perspective-origin) - [ ] [pointer-events](https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events) - [ ] [position](https://developer.mozilla.org/en-US/docs/Web/CSS/position) - [ ] [r](https://developer.mozilla.org/en-US/docs/Web/CSS/r) - [ ] [resize](https://developer.mozilla.org/en-US/docs/Web/CSS/resize) - [ ] [right](https://developer.mozilla.org/en-US/docs/Web/CSS/right) - [ ] [row-gap](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) - [ ] [ruby-position](https://developer.mozilla.org/en-US/docs/Web/CSS/ruby-position) - [ ] [rx](https://developer.mozilla.org/en-US/docs/Web/CSS/rx) - [ ] [ry](https://developer.mozilla.org/en-US/docs/Web/CSS/ry) - [ ] [scroll-behavior](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior) - [ ] [scroll-margin-block-end](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-block-end) - [ ] [scroll-margin-block-start](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-block-start) - [ ] [scroll-margin-inline-end](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-inline-end) - [ ] [scroll-margin-inline-start](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-inline-start) - [ ] [scroll-padding-block-end](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-block-end) - [ ] [scroll-padding-block-start](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-block-start) - [ ] [scroll-padding-inline-end](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-inline-end) - [ ] [scroll-padding-inline-start](https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-padding-inline-start) - [ ] [scrollbar-gutter](https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-gutter) - [ ] [shape-image-threshold](https://developer.mozilla.org/en-US/docs/Web/CSS/shape-image-threshold) - [ ] [shape-margin](https://developer.mozilla.org/en-US/docs/Web/CSS/shape-margin) - [ ] [shape-outside](https://developer.mozilla.org/en-US/docs/Web/CSS/shape-outside) - [ ] [shape-rendering](https://developer.mozilla.org/en-US/docs/Web/CSS/shape-rendering) - [ ] [speak](https://developer.mozilla.org/en-US/docs/Web/CSS/speak) - [ ] [stop-color](https://developer.mozilla.org/en-US/docs/Web/CSS/stop-color) - [ ] [stop-opacity](https://developer.mozilla.org/en-US/docs/Web/CSS/stop-opacity) - [ ] [stroke](https://developer.mozilla.org/en-US/docs/Web/CSS/stroke) - [ ] [stroke-dasharray](https://developer.mozilla.org/en-US/docs/Web/CSS/stroke-dasharray) - [ ] [stroke-dashoffset](https://developer.mozilla.org/en-US/docs/Web/CSS/stroke-dashoffset) - [ ] [stroke-linecap](https://developer.mozilla.org/en-US/docs/Web/CSS/stroke-linecap) - [ ] [stroke-linejoin](https://developer.mozilla.org/en-US/docs/Web/CSS/stroke-linejoin) - [ ] [stroke-miterlimit](https://developer.mozilla.org/en-US/docs/Web/CSS/stroke-miterlimit) - [ ] [stroke-opacity](https://developer.mozilla.org/en-US/docs/Web/CSS/stroke-opacity) - [ ] [stroke-width](https://developer.mozilla.org/en-US/docs/Web/CSS/stroke-width) - [ ] [tab-size](https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size) - [ ] [table-layout](https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout) - [ ] [text-align](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) - [ ] [text-align-last](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align-last) - [ ] [text-anchor](https://developer.mozilla.org/en-US/docs/Web/CSS/text-anchor) - [ ] [text-decoration](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration) - [ ] [text-decoration-color](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-color) - [ ] [text-decoration-line](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-line) - [ ] [text-decoration-skip-ink](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-skip-ink) - [ ] [text-decoration-style](https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration-style) - [ ] [text-indent](https://developer.mozilla.org/en-US/docs/Web/CSS/text-indent) - [ ] [text-overflow](https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow) - [ ] [text-rendering](https://developer.mozilla.org/en-US/docs/Web/CSS/text-rendering) - [ ] [text-shadow](https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow) - [ ] [text-size-adjust](https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust) - [ ] [text-transform](https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform) - [ ] [text-underline-position](https://developer.mozilla.org/en-US/docs/Web/CSS/text-underline-position) - [ ] [top](https://developer.mozilla.org/en-US/docs/Web/CSS/top) - [ ] [touch-action](https://developer.mozilla.org/en-US/docs/Web/CSS/touch-action) - [ ] [transform](https://developer.mozilla.org/en-US/docs/Web/CSS/transform) - [ ] [transform-origin](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-origin) - [ ] [transform-style](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-style) - [ ] [transition-delay](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-delay) - [ ] [transition-duration](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-duration) - [ ] [transition-property](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-property) - [ ] [transition-timing-function](https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function) - [ ] [unicode-bidi](https://developer.mozilla.org/en-US/docs/Web/CSS/unicode-bidi) - [ ] [user-select](https://developer.mozilla.org/en-US/docs/Web/CSS/user-select) - [ ] [vector-effect](https://developer.mozilla.org/en-US/docs/Web/CSS/vector-effect) - [ ] [vertical-align](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) - [ ] [visibility](https://developer.mozilla.org/en-US/docs/Web/CSS/visibility) - [ ] [white-space](https://developer.mozilla.org/en-US/docs/Web/CSS/white-space) - [ ] [widows](https://developer.mozilla.org/en-US/docs/Web/CSS/widows) - [ ] [width](https://developer.mozilla.org/en-US/docs/Web/CSS/width) - [ ] [will-change](https://developer.mozilla.org/en-US/docs/Web/CSS/will-change) - [ ] [word-break](https://developer.mozilla.org/en-US/docs/Web/CSS/word-break) - [ ] [word-spacing](https://developer.mozilla.org/en-US/docs/Web/CSS/word-spacing) - [ ] [writing-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/writing-mode) - [ ] [x](https://developer.mozilla.org/en-US/docs/Web/CSS/x) - [ ] [y](https://developer.mozilla.org/en-US/docs/Web/CSS/y) - [ ] [z-index](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index) - [ ] [zoom](https://developer.mozilla.org/en-US/docs/Web/CSS/zoom) - [ ] [-webkit-border-horizontal-spacing](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-border-horizontal-spacing) - [ ] [-webkit-border-image](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-border-image) - [ ] [-webkit-border-vertical-spacing](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-border-vertical-spacing) - [ ] [-webkit-box-align](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-box-align) - [ ] [-webkit-box-decoration-break](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-box-decoration-break) - [ ] [-webkit-box-direction](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-box-direction) - [ ] [-webkit-box-flex](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-box-flex) - [ ] [-webkit-box-ordinal-group](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-box-ordinal-group) - [ ] [-webkit-box-orient](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-box-orient) - [ ] [-webkit-box-pack](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-box-pack) - [ ] [-webkit-box-reflect](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-box-reflect) - [ ] [-webkit-font-smoothing](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-font-smoothing) - [ ] [-webkit-highlight](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-highlight) - [ ] [-webkit-hyphenate-character](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-hyphenate-character) - [ ] [-webkit-line-break](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-break) - [ ] [-webkit-line-clamp](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-line-clamp) - [ ] [-webkit-locale](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-locale) - [ ] [-webkit-mask-box-image](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-box-image) - [ ] [-webkit-mask-box-image-outset](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-box-image-outset) - [ ] [-webkit-mask-box-image-repeat](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-box-image-repeat) - [ ] [-webkit-mask-box-image-slice](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-box-image-slice) - [ ] [-webkit-mask-box-image-source](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-box-image-source) - [ ] [-webkit-mask-box-image-width](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-box-image-width) - [ ] [-webkit-mask-clip](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-clip) - [ ] [-webkit-mask-composite](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-composite) - [ ] [-webkit-mask-image](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-image) - [ ] [-webkit-mask-origin](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-origin) - [ ] [-webkit-mask-position](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-position) - [ ] [-webkit-mask-repeat](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-repeat) - [ ] [-webkit-mask-size](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-mask-size) - [ ] [-webkit-print-color-adjust](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) - [ ] [-webkit-rtl-ordering](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-rtl-ordering) - [ ] [-webkit-tap-highlight-color](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-tap-highlight-color) - [ ] [-webkit-text-combine](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-combine) - [ ] [-webkit-text-decorations-in-effect](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-decorations-in-effect) - [ ] [-webkit-text-emphasis-color](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-emphasis-color) - [ ] [-webkit-text-emphasis-position](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-emphasis-position) - [ ] [-webkit-text-emphasis-style](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-emphasis-style) - [ ] [-webkit-text-fill-color](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-fill-color) - [ ] [-webkit-text-orientation](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-orientation) - [ ] [-webkit-text-security](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-security) - [ ] [-webkit-text-stroke-color](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-stroke-color) - [ ] [-webkit-text-stroke-width](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-text-stroke-width) - [ ] [-webkit-user-drag](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-user-drag) - [ ] [-webkit-user-modify](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-user-modify) - [ ] [-webkit-writing-mode](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-writing-mode)
stephenwf commented 2 years ago

Summary of supported canvas styles:

Border / Outline Same rules for both, just border -> outline.

{ border: '1px solid red' }; // ✅ short hand properties
{ border: '1px solid rgb(255, 0, 0)' }; // ✅ RGB colour values (and other functions)
{ border: '1px solid rgba(255, 0, 0, .5)' }; // ✅ Colours with alpha
{ borderColor: 'red', borderWidth: '1px', borderStyle: 'solid' }; // ✅  borderXYZ properties

{ border: '1px 10px 0 0 solid red' };  // 🟡 Extra widths will be ignored, width will be 1px
{ border: '1em solid red' };  // 🟡 em/relative units will be read as pixels (1em -> 1px)

{ border: '1px dashed red' }; // ❌ Only "solid" supported currently
{ borderLeftWidth: '1px' }; // ❌ No per-side properties

Background Currently only backgroundColor is supported, and shorthand is not supported.

{ background: 'red' }; // ✅ shorthand background color
{ backgroundColor: 'red' }; // ✅ background colour property
{ backgroundColor: 'rgba(255, 0, 0, 0.5)' }; // ✅ background colour property with alpha

{ backgroundImage: 'url(...)' }; // ❌ No other types of background
{ backgroundRepeat: 'repeat' }; // ❌ No other types of background
{ background: 'linear-gradient(...)' }; // ❌ No shorthand background that is not a colour

Box shadow Most box shadows are supported. From the mozilla docs:

{ boxShadow: '10px 5px 5px red' }; // ✅ normal shadows
{ boxShadow: '60px -16px teal' }; // ✅ negative values and short hand props
{ boxShadow: '12px 12px 2px 1px rgba(0, 0, 255, .2)' }; // ✅ alpha colours
{ boxShadow: '3px 3px red, 4px 0 4px olive' }; // ✅ Multiple shadows

{ boxShadow: '5em 1em gold' }; // 🟡 em/relative units will be displays as pixels.

{ boxShadow: 'inset 5px 1px gold' }; // ❌ Inset shadows are not supported

Hover / active states Similar to CSS-in-JS libraries, you can style hover/active states for annotations.

{
  background: 'green',

  // Hover styles
  ':hover': {
    background: 'red'
  },

  // Active/pressed styles
  ':active': {
    background: 'blue'
  },
}

Note: active styles will be removed when your pointer/mouse leaves the box. This is slightly different to browser behaviour.

stephenwf commented 2 years ago

HTML rendering

If you want to style something using CSS/HTML without these limitations then you can. Adding a classname to an annotation or annotation-list will de-optimise it. The style properties above will continue to work, but without the states limitations (and all other CSS properties).

However, due to how web components work, you can't apply CSS directly with a class name. You need to link your CSS to the web component. There are 3 ways to achieve this.

CSS styling

There are 3 ways of styling with CSS.

1. Reference an external stylesheet.

<canvas-panel stylesheet="/annotations.css" annotation-css-class="example-annotation" />

2. Reference a style tag

<style id="my-style">
  .example-annotation {
    background: red;
  }
</style>

...

<canvas-panel style-id="my-style" annotation-css-class="example-annotation" />

3. Using CSS ::part selector

<style>
  /* ✅ tip: you can optionally add a class name if you have multiple */
  canvas-panel.custom-class::part(example-annotation) {
    background: red;  
  }
</style>

<canvas-panel class="custom-class" annotation-css-class="example-annotation" />

CSS using the ::part selector can be in external or inline stylesheets. The part will always match the classname.

Hover / Active states

In the underlying viewer, although you may have an HTML <div /> to represent an annotation, that doesn't mean that pointer events will be handled by that element. All events are handled internally by the viewer by default. This allows panning, zooming and other event handlers to continue to work with a mix of canvas and HTML elements. One side effect of this is that your CSS class may not work with states. For example:

<style>
  .my-annotation {
    background: red;
  }
  .my-annotation:hover { /* ❌ :hover may not react to pointer events */
    background: blue;
  }

  canvas-panel::part(my-annotation) {
    background: red;
  }
  canvas-panel::part(my-annotation):hover { /* ❌ :hover may not react to pointer events */
    background: blue;
  }
</style>

May not work as expected. When you hover in atlas, we will take your class name and append --hover or --active to the class name. The following style is recommended:

<style>
  /** Using CSS classes **/

  .my-annotation {
    background: red;
  }
  .my-annotation--hover, /* ✅ covers both types of hover */
  .my-annotation:hover { 
    background: blue;
  }
  .my-annotation--active,  /* ✅ covers both types of active */
  .my-annotation:hover:active { 
    background: orange;
  }

  /** Using CSS ::part() **/

  canvas-panel::part(my-annotation) {
    background: red;
  }
  canvas-panel::part(my-annotation):hover,
  canvas-panel::part(my-annotation--hover) { /* ✅ covers both types of hover */
    background: blue;
  }
  canvas-panel::part(my-annotation):hover:active,
  canvas-panel::part(my-annotation--active) { /* ✅ covers both types of active */
    background: orange;
  }
</style>

Canvas panel attributes

There are a few attributes on the canvas panel component that you can set to control which class names appear on annotations.

annotation-css-class

This is a catch all, this will convert all annotations rendered to use the HTML renderer and will not be drawn on canvas. They will have a class AND part matching the value of this property. So annotation-css-class="my-anno" would set class="my-annot" and part="my-anno" for your styling needs.

highlight-css-class

This is to be used in conjunction with the highlight="100,200,300,400" where highlight is a box selector xywh. This CSS class will only apply to that highlight annotation.

linking-css-class

This is to be used in conjunction with the follow-annotations="true" property and text-enabled="true"