Commit c2ca6c8f authored by Lyza Danger Gardner's avatar Lyza Danger Gardner

Fix layout of `AnnotationPublishControl` for Safari

* Add a wrapper element around the `Menu` component and apply styles
  to make sure it stretches/fills vertical space in parent
* Add utility class for small icon styling

Fixes #2302
parent 7da63a83
...@@ -58,10 +58,7 @@ function AnnotationPublishControl({ ...@@ -58,10 +58,7 @@ function AnnotationPublishControl({
className="annotation-publish-button__menu-label" className="annotation-publish-button__menu-label"
style={applyTheme(themeProps, settings)} style={applyTheme(themeProps, settings)}
> >
<SvgIcon <SvgIcon name="expand-menu" className="u-icon--small" />
name="expand-menu"
className="annotation-publish-button__menu-icon"
/>
</div> </div>
); );
...@@ -76,28 +73,32 @@ function AnnotationPublishControl({ ...@@ -76,28 +73,32 @@ function AnnotationPublishControl({
title={`Publish this annotation to ${publishDestination}`} title={`Publish this annotation to ${publishDestination}`}
buttonText={`Post to ${publishDestination}`} buttonText={`Post to ${publishDestination}`}
/> />
<Menu {/* This wrapper div is necessary because of peculiarities with
arrowClass="annotation-publish-button__menu-arrow" Safari: see https://github.com/hypothesis/client/issues/2302 */}
containerPositioned={false} <div className="annotation-publish-button__menu-wrapper">
contentClass="annotation-publish-button__menu-content" <Menu
label={menuLabel} arrowClass="annotation-publish-button__menu-arrow"
menuIndicator={false} containerPositioned={false}
title="Change annotation sharing setting" contentClass="annotation-publish-button__menu-content"
align="left" label={menuLabel}
> menuIndicator={false}
<MenuItem title="Change annotation sharing setting"
icon={group.type === 'open' ? 'public' : 'groups'} align="left"
label={group.name} >
isSelected={!isPrivate} <MenuItem
onClick={() => onSetPrivacy('shared')} icon={group.type === 'open' ? 'public' : 'groups'}
/> label={group.name}
<MenuItem isSelected={!isPrivate}
icon="lock" onClick={() => onSetPrivacy('shared')}
label="Only Me" />
isSelected={isPrivate} <MenuItem
onClick={() => onSetPrivacy('private')} icon="lock"
/> label="Only Me"
</Menu> isSelected={isPrivate}
onClick={() => onSetPrivacy('private')}
/>
</Menu>
</div>
</div> </div>
<div> <div>
<Button <Button
......
...@@ -14,11 +14,13 @@ ...@@ -14,11 +14,13 @@
} }
} }
// A split button with a primary submit on the left and a drop-down menu // A split control with a primary submit button on the left
// of related options to the right // (.annotation-publish-button__primary) and a drop-down menu for changing
// the annotation's privacy settings on the right
// (within .annotation-publish-button__menu-wrapper)
.annotation-publish-button { .annotation-publish-button {
@include layout.row; @include layout.row;
// For proper menu alignment // To allow absolute menu alignment
position: relative; position: relative;
// Align the menu (upward) arrow correctly with the ▼ in the menu label icon // Align the menu (upward) arrow correctly with the ▼ in the menu label icon
...@@ -33,37 +35,36 @@ ...@@ -33,37 +35,36 @@
min-width: 100%; min-width: 100%;
} }
// The left side of the control (the publish button)
&__primary { &__primary {
@include buttons.button--primary; @include buttons.button--primary;
padding: var.$layout-space--small; padding: var.$layout-space--small;
// Turn off right-side border radius for alignment with menu label/button // Turn off right-side border radius for alignment with the right side of
// the control
border-top-right-radius: 0; border-top-right-radius: 0;
border-bottom-right-radius: 0; border-bottom-right-radius: 0;
} }
// dropdown arrow which reveals the button's associated menu // The right side of the control (the privacy `Menu`)
// when clicked
&__menu-label {
@include layout.row(center);
@include layout.horizontal-space(var.$layout-space--small);
color: var.$color-text-inverted;
background-color: var.$grey-mid;
// Make sure label element takes up full available vertical space
height: 100%;
// This wrapper element styling is necessary to account for a peculiarity in
// Safari. See https://github.com/hypothesis/client/issues/2302
&__menu-wrapper {
@include layout.row;
// Add border radius to the right to match the left side of the primary button // Add border radius to the right to match the left side of the primary button
border-top-right-radius: var.$border-radius; border-top-right-radius: var.$border-radius;
border-bottom-right-radius: var.$border-radius; border-bottom-right-radius: var.$border-radius;
background-color: var.$grey-mid;
&:hover { &:hover {
background-color: var.$grey-6; background-color: var.$grey-6;
} }
} }
&__menu-icon { // dropdown arrow which reveals the associated `Menu` when clicked
@include utils.icon--small; &__menu-label {
// To properly vertically center menu-label icon padding: var.$layout-space--small;
height: 100%; color: var.$color-text-inverted;
} }
} }
...@@ -63,6 +63,10 @@ ...@@ -63,6 +63,10 @@
@include utils.icon--xsmall; @include utils.icon--xsmall;
} }
.u-icon--small {
@include utils.icon--small;
}
.u-icon--large { .u-icon--large {
@include utils.icon--large; @include utils.icon--large;
} }
......
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