Commit cdd0164f authored by Robert Knight's avatar Robert Knight

Convert `AdderToolbar` CSS classes to current conventions

Rename all CSS classes used by the `AdderToolbar` component to follow
the `Component__element--modifier` syntax that we use for other
components. Also rename the `Adder.scss` file to match the Preact
component name.
parent 59c8ead0
...@@ -19,16 +19,16 @@ function ToolbarButton({ badgeCount, icon, label, onClick, shortcut }) { ...@@ -19,16 +19,16 @@ function ToolbarButton({ badgeCount, icon, label, onClick, shortcut }) {
return ( return (
<button <button
className="annotator-adder-button" className="AdderToolbar__button"
onClick={onClick} onClick={onClick}
aria-label={title} aria-label={title}
title={title} title={title}
> >
{icon && <SvgIcon name={icon} className="annotator-adder-button__icon" />} {icon && <SvgIcon name={icon} className="AdderToolbar__icon" />}
{typeof badgeCount === 'number' && ( {typeof badgeCount === 'number' && (
<span className="annotator-adder-button__badge">{badgeCount}</span> <span className="AdderToolbar__badge">{badgeCount}</span>
)} )}
<span className="annotator-adder-button__label">{label}</span> <span className="AdderToolbar__label">{label}</span>
</button> </button>
); );
} }
...@@ -91,14 +91,14 @@ export default function AdderToolbar({ ...@@ -91,14 +91,14 @@ export default function AdderToolbar({
// so that we can compute its size in order to position it before display. // so that we can compute its size in order to position it before display.
return ( return (
<div <div
className={classnames('annotator-adder', { className={classnames('AdderToolbar', {
'annotator-adder--down': arrowDirection === 'up', 'AdderToolbar--down': arrowDirection === 'up',
'annotator-adder--up': arrowDirection === 'down', 'AdderToolbar--up': arrowDirection === 'down',
'is-active': isVisible, 'is-active': isVisible,
})} })}
style={{ visibility: isVisible ? 'visible' : 'hidden' }} style={{ visibility: isVisible ? 'visible' : 'hidden' }}
> >
<div className="annotator-adder-actions"> <div className="AdderToolbar__actions">
<ToolbarButton <ToolbarButton
icon="annotate" icon="annotate"
onClick={e => handleCommand(e, 'annotate')} onClick={e => handleCommand(e, 'annotate')}
...@@ -111,9 +111,7 @@ export default function AdderToolbar({ ...@@ -111,9 +111,7 @@ export default function AdderToolbar({
label="Highlight" label="Highlight"
shortcut={highlightShortcut} shortcut={highlightShortcut}
/> />
{annotationCount > 0 && ( {annotationCount > 0 && <div className="AdderToolbar__separator" />}
<div className="annotator-adder-actions__separator" />
)}
{annotationCount > 0 && ( {annotationCount > 0 && (
<ToolbarButton <ToolbarButton
badgeCount={annotationCount} badgeCount={annotationCount}
...@@ -126,9 +124,9 @@ export default function AdderToolbar({ ...@@ -126,9 +124,9 @@ export default function AdderToolbar({
<SvgIcon <SvgIcon
name="pointer" name="pointer"
inline={true} inline={true}
className={classnames('annotator-adder-arrow', { className={classnames('AdderToolbar__arrow', {
'annotator-adder-arrow--down': arrowDirection === 'down', 'AdderToolbar__arrow--down': arrowDirection === 'down',
'annotator-adder-arrow--up': arrowDirection === 'up', 'AdderToolbar__arrow--up': arrowDirection === 'up',
})} })}
/> />
</div> </div>
......
...@@ -84,7 +84,7 @@ describe('Adder', () => { ...@@ -84,7 +84,7 @@ describe('Adder', () => {
new Adder(adderEl, adderCallbacks); new Adder(adderEl, adderCallbacks);
assert.called(adderEl.attachShadow); assert.called(adderEl.attachShadow);
assert.isTrue(shadowEl.childNodes[0].classList.contains('annotator-adder')); assert.isTrue(shadowEl.childNodes[0].classList.contains('AdderToolbar'));
adderEl.remove(); adderEl.remove();
}); });
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
@use '@hypothesis/frontend-shared/styles'; @use '@hypothesis/frontend-shared/styles';
// Annotator-specific components. // Annotator-specific components.
@use './components/Adder'; @use './components/AdderToolbar';
@use './components/Toolbar'; @use './components/Toolbar';
@use './bucket-bar'; @use './bucket-bar';
@use './highlights'; @use './highlights';
......
...@@ -8,7 +8,7 @@ $adder-transition-duration: 80ms; ...@@ -8,7 +8,7 @@ $adder-transition-duration: 80ms;
// Main class for the root element of the "adder" toolbar that appears when the // Main class for the root element of the "adder" toolbar that appears when the
// user makes a text selection. // user makes a text selection.
.annotator-adder { .AdderToolbar {
// Reset all inherited properties to their initial values. This prevents CSS // Reset all inherited properties to their initial values. This prevents CSS
// property values from the host page being inherited by elements of the // property values from the host page being inherited by elements of the
// Adder, even when using Shadow DOM. // Adder, even when using Shadow DOM.
...@@ -49,7 +49,7 @@ $adder-transition-duration: 80ms; ...@@ -49,7 +49,7 @@ $adder-transition-duration: 80ms;
} }
} }
.annotator-adder-arrow { .AdderToolbar__arrow {
@include molecules.menu-arrow; @include molecules.menu-arrow;
// Horizontal centering, part 1 // Horizontal centering, part 1
left: 50%; left: 50%;
...@@ -74,11 +74,11 @@ $adder-transition-duration: 80ms; ...@@ -74,11 +74,11 @@ $adder-transition-duration: 80ms;
} }
} }
.annotator-adder-actions { .AdderToolbar__actions {
@include layout.row; @include layout.row;
} }
.annotator-adder-button { .AdderToolbar__button {
@include layout.column($align: center); @include layout.column($align: center);
@include buttons.reset-native-btn-styles; @include buttons.reset-native-btn-styles;
...@@ -88,13 +88,14 @@ $adder-transition-duration: 80ms; ...@@ -88,13 +88,14 @@ $adder-transition-duration: 80ms;
line-height: var.$annotator-adder-line-height; line-height: var.$annotator-adder-line-height;
padding: var.$layout-space--small; padding: var.$layout-space--small;
transition: color $adder-transition-duration; transition: color $adder-transition-duration;
}
&__label { .AdderToolbar__label {
margin-top: var.$layout-space--xxsmall; margin-top: var.$layout-space--xxsmall;
transition: color $adder-transition-duration; transition: color $adder-transition-duration;
} }
&__badge { .AdderToolbar__badge {
// The badge should be vertically aligned with icons in other toolbar buttons // The badge should be vertically aligned with icons in other toolbar buttons
// and the label underneath should also align with labels in other buttons. // and the label underneath should also align with labels in other buttons.
background-color: var.$grey-mid; background-color: var.$grey-mid;
...@@ -103,10 +104,9 @@ $adder-transition-duration: 80ms; ...@@ -103,10 +104,9 @@ $adder-transition-duration: 80ms;
font-weight: bold; font-weight: bold;
// For positioning the number appropriately withint the badge background // For positioning the number appropriately withint the badge background
padding: 2px 4px; padding: 2px 4px;
}
} }
.annotator-adder-actions__separator { .AdderToolbar__separator {
margin: var.$layout-space--xxsmall; margin: var.$layout-space--xxsmall;
@include utils.border--right; @include utils.border--right;
// Override border color to be a little darker // Override border color to be a little darker
...@@ -115,11 +115,11 @@ $adder-transition-duration: 80ms; ...@@ -115,11 +115,11 @@ $adder-transition-duration: 80ms;
// The toolbar has full contrast when not hovered. When the toolbar is hovered, // The toolbar has full contrast when not hovered. When the toolbar is hovered,
// the buttons are dimmed except for the one which is currently hovered. // the buttons are dimmed except for the one which is currently hovered.
.annotator-adder-actions:hover { .AdderToolbar__actions:hover {
.annotator-adder-button:not(:hover) { .AdderToolbar__button:not(:hover) {
color: var.$grey-semi; color: var.$grey-semi;
.annotator-adder-button__badge { .AdderToolbar__badge {
background-color: var.$grey-semi; background-color: var.$grey-semi;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment