Unverified Commit 16748dd6 authored by Lyza Gardner's avatar Lyza Gardner Committed by GitHub

Merge pull request #2265 from hypothesis/reduce-reuse-recycle

Do additional consolidation with mixins and remove unused CSS
parents 488a9db6 6f93f1b8
...@@ -76,7 +76,7 @@ function AnnotationActionBar({ ...@@ -76,7 +76,7 @@ function AnnotationActionBar({
}; };
return ( return (
<div className="annotation-action-bar"> <div className="annotation-action-bar u-layout-row">
{showEditAction && <Button icon="edit" title="Edit" onClick={onEdit} />} {showEditAction && <Button icon="edit" title="Edit" onClick={onEdit} />}
{showDeleteAction && ( {showDeleteAction && (
<Button icon="trash" title="Delete" onClick={onDelete} /> <Button icon="trash" title="Delete" onClick={onDelete} />
......
...@@ -104,7 +104,7 @@ function AnnotationShareControl({ ...@@ -104,7 +104,7 @@ function AnnotationShareControl({
<div className="annotation-share-panel__input"> <div className="annotation-share-panel__input">
<input <input
aria-label="Use this URL to share this annotation" aria-label="Use this URL to share this annotation"
className="form-input" className="annotation-share-panel__form-input"
type="text" type="text"
value={shareUri} value={shareUri}
readOnly readOnly
......
...@@ -99,15 +99,15 @@ function HelpPanel({ auth, session }) { ...@@ -99,15 +99,15 @@ function HelpPanel({ auth, session }) {
panelName={uiConstants.PANEL_HELP} panelName={uiConstants.PANEL_HELP}
onActiveChanged={onActiveChanged} onActiveChanged={onActiveChanged}
> >
<div className="help-panel__content"> <div className="help-panel__content u-vertical-rhythm">
<div className="help-panel__subtitle"> <div className="u-layout-row--align-middle">
<h3 className="help-panel__sub-panel-title"> <h3 className="help-panel__sub-panel-title">
{subPanelTitles[activeSubPanel]} {subPanelTitles[activeSubPanel]}
</h3> </h3>
<div className="help-panel__navigation"> <div>
{activeSubPanel === 'versionInfo' && ( {activeSubPanel === 'versionInfo' && (
<button <button
className="help-panel__sub-panel-link" className="help-panel__sub-panel-navigation-button"
onClick={e => openSubPanel(e, 'tutorial')} onClick={e => openSubPanel(e, 'tutorial')}
aria-label="Show tutorial panel" aria-label="Show tutorial panel"
> >
...@@ -120,15 +120,12 @@ function HelpPanel({ auth, session }) { ...@@ -120,15 +120,12 @@ function HelpPanel({ auth, session }) {
)} )}
{activeSubPanel === 'tutorial' && ( {activeSubPanel === 'tutorial' && (
<button <button
className="help-panel__sub-panel-link" className="help-panel__sub-panel-navigation-button"
onClick={e => openSubPanel(e, 'versionInfo')} onClick={e => openSubPanel(e, 'versionInfo')}
aria-label="Show version information panel" aria-label="Show version information panel"
> >
About this version About this version
<SvgIcon <SvgIcon name="arrow-right" />
name="arrow-right"
className="help-panel__sub-panel-link-icon"
/>
</button> </button>
)} )}
</div> </div>
......
...@@ -71,7 +71,7 @@ function ShareAnnotationsPanel({ analytics, toastMessenger }) { ...@@ -71,7 +71,7 @@ function ShareAnnotationsPanel({ analytics, toastMessenger }) {
<div className="share-annotations-panel__input"> <div className="share-annotations-panel__input">
<input <input
aria-label="Use this URL to share these annotations" aria-label="Use this URL to share these annotations"
className="form-input share-annotations-panel__form-input" className="share-annotations-panel__form-input"
type="text" type="text"
value={shareURI} value={shareURI}
readOnly readOnly
......
...@@ -58,14 +58,16 @@ describe('HelpPanel', function () { ...@@ -58,14 +58,16 @@ describe('HelpPanel', function () {
it('should show navigation link to versionInfo sub-panel', () => { it('should show navigation link to versionInfo sub-panel', () => {
const wrapper = createComponent(); const wrapper = createComponent();
const link = wrapper.find('.help-panel__sub-panel-link'); const link = wrapper.find('.help-panel__sub-panel-navigation-button');
assert.equal(link.text(), 'About this version'); assert.equal(link.text(), 'About this version');
}); });
it('should switch to versionInfo sub-panel when footer link clicked', () => { it('should switch to versionInfo sub-panel when footer link clicked', () => {
const wrapper = createComponent(); const wrapper = createComponent();
wrapper.find('.help-panel__sub-panel-link').simulate('click'); wrapper
.find('.help-panel__sub-panel-navigation-button')
.simulate('click');
assert.equal( assert.equal(
wrapper.find('.help-panel__sub-panel-title').text(), wrapper.find('.help-panel__sub-panel-title').text(),
...@@ -83,9 +85,11 @@ describe('HelpPanel', function () { ...@@ -83,9 +85,11 @@ describe('HelpPanel', function () {
context('when viewing versionInfo sub-panel', () => { context('when viewing versionInfo sub-panel', () => {
it('should show navigation link back to tutorial sub-panel', () => { it('should show navigation link back to tutorial sub-panel', () => {
const wrapper = createComponent(); const wrapper = createComponent();
wrapper.find('.help-panel__sub-panel-link').simulate('click'); wrapper
.find('.help-panel__sub-panel-navigation-button')
.simulate('click');
const link = wrapper.find('.help-panel__sub-panel-link'); const link = wrapper.find('.help-panel__sub-panel-navigation-button');
assert.isTrue(wrapper.find('VersionInfo').exists()); assert.isTrue(wrapper.find('VersionInfo').exists());
assert.isFalse(wrapper.find('Tutorial').exists()); assert.isFalse(wrapper.find('Tutorial').exists());
...@@ -96,9 +100,11 @@ describe('HelpPanel', function () { ...@@ -96,9 +100,11 @@ describe('HelpPanel', function () {
const wrapper = createComponent(); const wrapper = createComponent();
// Click to get to version-info sub-panel... // Click to get to version-info sub-panel...
wrapper.find('.help-panel__sub-panel-link').simulate('click'); wrapper
.find('.help-panel__sub-panel-navigation-button')
.simulate('click');
const link = wrapper.find('.help-panel__sub-panel-link'); const link = wrapper.find('.help-panel__sub-panel-navigation-button');
// Click again to get back to tutorial sub-panel // Click again to get back to tutorial sub-panel
link.simulate('click'); link.simulate('click');
......
...@@ -133,3 +133,19 @@ ...@@ -133,3 +133,19 @@
text-decoration: underline; text-decoration: underline;
} }
} }
/**
* A button pattern that looks like a link with a small icon on the right
* Used, e.g., in the help panel to navigate between sub-panels
*/
@mixin button--navigation {
@include reset-native-btn-styles;
@include layout.row($justify: right, $align: center);
color: var.$color-brand;
svg {
margin-left: 2px;
width: 12px;
height: 12px;
}
}
...@@ -49,6 +49,12 @@ ...@@ -49,6 +49,12 @@
} }
} }
@mixin form-input--with-button {
@include form-input;
width: 100%;
border-radius: 0;
}
@mixin primary-action-btn { @mixin primary-action-btn {
@include focus.outline-on-keyboard-focus; @include focus.outline-on-keyboard-focus;
@include utils.font--medium; @include utils.font--medium;
......
@use '../../mixins/buttons'; @use '../../mixins/buttons';
@use '../../mixins/forms';
@use '../../mixins/layout'; @use '../../mixins/layout';
@use '../../mixins/molecules'; @use '../../mixins/molecules';
@use "../../mixins/utils"; @use "../../mixins/utils";
...@@ -14,7 +15,6 @@ ...@@ -14,7 +15,6 @@
right: 5px; right: 5px;
bottom: 32px; bottom: 32px;
width: 275px; width: 275px;
box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.15);
cursor: default; cursor: default;
&__input { &__input {
...@@ -26,10 +26,10 @@ ...@@ -26,10 +26,10 @@
padding: 0.25em 0.5em; padding: 0.25em 0.5em;
} }
& .form-input { &__form-input {
@include forms.form-input--with-button;
@include utils.font--small; @include utils.font--small;
padding: 0.5em; padding: 0.5em;
border-radius: 0;
} }
&__permissions { &__permissions {
......
...@@ -4,13 +4,5 @@ ...@@ -4,13 +4,5 @@
&__user-name { &__user-name {
color: var.$color-text; color: var.$color-text;
font-weight: bold; font-weight: bold;
.is-dimmed & {
color: var.$color-text-light;
}
.is-highlighted & {
color: var.$color-text;
}
} }
} }
...@@ -24,23 +24,6 @@ ...@@ -24,23 +24,6 @@
.annotation { .annotation {
@include layout.vertical-rhythm; @include layout.vertical-rhythm;
&.is-highlighted {
// Slightly darken the bodies of highlighted annotations to
// make them stand out next to others, which will have the `is-dimmed` state
// set
.annotation-body {
color: var.$color-text;
}
}
&.is-dimmed {
// Lighten the bodies of dimmed annotations to make other
// annotations which are not dimmed stand out
.annotation-body {
color: var.$color-text-light;
}
}
&__reply-toggle { &__reply-toggle {
@include buttons.button--link; @include buttons.button--link;
} }
......
@use "../../mixins/focus"; @use "../../mixins/focus";
@use "../../mixins/forms"; @use "../../mixins/forms";
@use "../../mixins/layout"; @use "../../mixins/layout";
@use "../../mixins/molecules";
@use "../../mixins/utils"; @use "../../mixins/utils";
@use "../../variables" as var; @use "../../variables" as var;
// A dark grey button used for the primary action // A dark grey button used for the primary action
// in a form // in a form
.focused-mode-header { .focused-mode-header {
@include molecules.card-frame;
@include layout.row($align: center); @include layout.row($align: center);
@include utils.border;
position: relative; position: relative;
background-color: var.$color-background; background-color: var.$color-background;
border-radius: 2px; border-radius: 2px;
font-weight: 300; font-weight: 300;
margin-bottom: 0.72em;
padding: 0.5em 1em; // TODO cleanup
padding: 0.5em;
margin-bottom: 1em;
&__btn { &__btn {
// TODO use Button component
@include forms.primary-action-btn; @include forms.primary-action-btn;
@include layout.row($align: center); @include layout.row($align: center);
margin-left: auto; margin-left: auto;
......
@use "../../mixins/forms";
@use "../../variables" as var;
.form-input {
@include forms.form-input;
width: 100%;
display: block;
}
@use "../../mixins/buttons"; @use "../../mixins/buttons";
@use "../../mixins/layout"; @use "../../mixins/layout";
@use "../../mixins/molecules";
@use "../../mixins/utils"; @use "../../mixins/utils";
@use "../../variables" as var; @use "../../variables" as var;
.help-panel { .help-panel {
&__content {
@include layout.vertical_rhythm;
}
&__subtitle {
@include layout.row($justify: right, $align: center);
}
&__sub-panel-title { &__sub-panel-title {
@include utils.font--large; @include utils.font--large;
flex-grow: 1; flex-grow: 1;
...@@ -20,7 +13,6 @@ ...@@ -20,7 +13,6 @@
&__subcontent { &__subcontent {
@include utils.border-top; @include utils.border-top;
@include utils.border-bottom; @include utils.border-bottom;
padding: 0.5em 0;
a { a {
text-decoration: underline; text-decoration: underline;
...@@ -31,40 +23,11 @@ ...@@ -31,40 +23,11 @@
@include utils.icon--xsmall; @include utils.icon--xsmall;
} }
&__sub-panel-link { &__sub-panel-navigation-button {
@include buttons.reset-native-btn-styles; @include buttons.button--navigation;
@include layout.row($align: center);
margin-left: auto;
color: var.$color-brand;
&-icon {
margin-left: 2px;
width: 12px;
height: 12px;
}
} }
&-tabs { &-tabs {
@include layout.row($align: center); @include molecules.panel-tabs;
&__tab {
@include utils.font--large;
@include utils.border-right;
flex: 1 1;
text-align: center;
color: var.$color-text-light;
&:last-of-type {
border-right: none;
}
}
&__link {
color: var.$color-text-light;
}
&__icon {
@include utils.icon--xsmall;
}
} }
} }
@use "../../variables" as var; @use "../../variables" as var;
@use "../../mixins/buttons"; @use "../../mixins/buttons";
@use "../../mixins/utils"; @use "../../mixins/forms";
@use "../../mixins/molecules"; @use "../../mixins/molecules";
@use "../../mixins/utils";
.share-annotations-panel { .share-annotations-panel {
color: var.$color-text-light; color: var.$color-text-light;
...@@ -16,7 +17,7 @@ ...@@ -16,7 +17,7 @@
} }
&__form-input { &__form-input {
border-radius: 0; @include forms.form-input--with-button;
} }
&__icon--inline { &__icon--inline {
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
// Components // Components
// ---------- // ----------
@use './components/annotation-action-bar';
@use './components/annotation'; @use './components/annotation';
@use './components/annotation-body'; @use './components/annotation-body';
@use './components/annotation-document-info'; @use './components/annotation-document-info';
...@@ -28,7 +27,6 @@ ...@@ -28,7 +27,6 @@
@use './components/button'; @use './components/button';
@use './components/excerpt'; @use './components/excerpt';
@use './components/focused-mode-header'; @use './components/focused-mode-header';
@use './components/form-input';
@use './components/group-list'; @use './components/group-list';
@use './components/group-list-item'; @use './components/group-list-item';
@use './components/help-panel'; @use './components/help-panel';
......
...@@ -10,6 +10,15 @@ ...@@ -10,6 +10,15 @@
@include layout.row; @include layout.row;
} }
.u-layout-row--align-center,
.u-layout-row--align-middle {
@include layout.row($align: center);
}
.u-vertical-rhythm {
@include layout.vertical-rhythm;
}
.u-screen-reader-only { .u-screen-reader-only {
@include a11y.screen-reader-only; @include a11y.screen-reader-only;
} }
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