Commit 0edbc1ba authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Update Notebook components to use shared button components

parent d1cc0a07
...@@ -3,8 +3,7 @@ import classnames from 'classnames'; ...@@ -3,8 +3,7 @@ import classnames from 'classnames';
import { createSidebarConfig } from '../config/sidebar'; import { createSidebarConfig } from '../config/sidebar';
// FIXME: use the button from the frontend shared package once this is stable. import { LabeledButton } from '../../shared/components/buttons';
import Button from '../../sidebar/components/Button';
/** /**
* @typedef NotebookIframeProps * @typedef NotebookIframeProps
...@@ -102,13 +101,16 @@ export default function NotebookModal({ eventBus, config }) { ...@@ -102,13 +101,16 @@ export default function NotebookModal({ eventBus, config }) {
return ( return (
<div className={classnames('Notebook__outer', { 'is-hidden': isHidden })}> <div className={classnames('Notebook__outer', { 'is-hidden': isHidden })}>
<div className="Notebook__inner"> <div className="Notebook__inner">
<Button <div className="Notebook__close-button-container">
<LabeledButton
icon="cancel" icon="cancel"
className="Notebook__close-button"
buttonText="Close"
title="Close the Notebook" title="Close the Notebook"
onClick={onClose} onClick={onClose}
/> variant="dark"
>
Close
</LabeledButton>
</div>
{groupId !== null && ( {groupId !== null && (
<NotebookIframe key={iframeKey} config={config} groupId={groupId} /> <NotebookIframe key={iframeKey} config={config} groupId={groupId} />
)} )}
......
...@@ -109,7 +109,7 @@ describe('NotebookModal', () => { ...@@ -109,7 +109,7 @@ describe('NotebookModal', () => {
assert.isFalse(outer.hasClass('is-hidden')); assert.isFalse(outer.hasClass('is-hidden'));
act(() => { act(() => {
wrapper.find('Button').prop('onClick')(); wrapper.find('LabeledButton').prop('onClick')();
}); });
wrapper.update(); wrapper.update();
...@@ -125,7 +125,7 @@ describe('NotebookModal', () => { ...@@ -125,7 +125,7 @@ describe('NotebookModal', () => {
}); });
assert.equal(document.body.style.overflow, 'hidden'); assert.equal(document.body.style.overflow, 'hidden');
act(() => { act(() => {
wrapper.find('Button').prop('onClick')(); wrapper.find('LabeledButton').prop('onClick')();
}); });
assert.notEqual(document.body.style.overflow, 'hidden'); assert.notEqual(document.body.style.overflow, 'hidden');
}); });
......
import { pageNumberOptions } from '../util/pagination'; import { pageNumberOptions } from '../util/pagination';
import Button from './Button'; import { LabeledButton } from '../../shared/components/buttons';
/** /**
* @typedef PaginationNavigationProps * @typedef PaginationNavigationProps
...@@ -35,13 +35,15 @@ function PaginationNavigation({ currentPage, onChangePage, totalPages }) { ...@@ -35,13 +35,15 @@ function PaginationNavigation({ currentPage, onChangePage, totalPages }) {
<div className="PaginationNavigation"> <div className="PaginationNavigation">
<div className="PaginationNavigation__relative PaginationNavigation__prev"> <div className="PaginationNavigation__relative PaginationNavigation__prev">
{hasPreviousPage && ( {hasPreviousPage && (
<Button <LabeledButton
className="PaginationNavigation__button" className="PaginationPageButton"
icon="arrow-left" icon="arrow-left"
buttonText="prev"
title="Go to previous page" title="Go to previous page"
onClick={e => changePageTo(currentPage - 1, e.target)} onClick={e => changePageTo(currentPage - 1, e.target)}
/> variant="dark"
>
prev
</LabeledButton>
)} )}
</div> </div>
<ul className="PaginationNavigation__pages"> <ul className="PaginationNavigation__pages">
...@@ -50,28 +52,32 @@ function PaginationNavigation({ currentPage, onChangePage, totalPages }) { ...@@ -50,28 +52,32 @@ function PaginationNavigation({ currentPage, onChangePage, totalPages }) {
{page === null ? ( {page === null ? (
<div className="PaginationNavigation__gap">...</div> <div className="PaginationNavigation__gap">...</div>
) : ( ) : (
<Button <LabeledButton
className="PaginationPageButton"
key={`page-${idx}`} key={`page-${idx}`}
buttonText={page.toString()}
title={`Go to page ${page}`} title={`Go to page ${page}`}
className="PaginationNavigation__page-button" pressed={page === currentPage}
isPressed={page === currentPage}
onClick={e => changePageTo(page, e.target)} onClick={e => changePageTo(page, e.target)}
/> variant="dark"
>
{page.toString()}
</LabeledButton>
)} )}
</li> </li>
))} ))}
</ul> </ul>
<div className="PaginationNavigation__relative PaginationNavigation__next"> <div className="PaginationNavigation__relative PaginationNavigation__next">
{hasNextPage && ( {hasNextPage && (
<Button <LabeledButton
className="PaginationNavigation__button PaginationNavigation__button-right" className="PaginationPageButton"
icon="arrow-right" icon="arrow-right"
buttonText="next"
iconPosition="right" iconPosition="right"
title="Go to next page" title="Go to next page"
onClick={e => changePageTo(currentPage + 1, e.target)} onClick={e => changePageTo(currentPage + 1, e.target)}
/> variant="dark"
>
next
</LabeledButton>
)} )}
</div> </div>
</div> </div>
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
// ----------------- // -----------------
@use '@hypothesis/frontend-shared/styles'; @use '@hypothesis/frontend-shared/styles';
// Shared button styles (TEMPORARY)
@use '../shared';
// Annotator-specific components. // Annotator-specific components.
@use './components/AdderToolbar'; @use './components/AdderToolbar';
@use './components/Buckets'; @use './components/Buckets';
......
...@@ -39,11 +39,10 @@ ...@@ -39,11 +39,10 @@
border: none; border: none;
} }
.Notebook__close-button { .Notebook__close-button-container {
position: absolute; position: absolute;
right: 0; right: 0;
font-size: var.$font-size--large; font-size: var.$font-size--large;
@include buttons.button--primary;
margin: var.$layout-space--xsmall; margin: var.$layout-space--xsmall;
cursor: pointer; cursor: pointer;
} }
@use '../variables' as var;
// Button styling for the sidebar extending common button-component styles // Button styling for the sidebar extending common button-component styles
@use '../shared/components/buttons/mixins' as buttons; @use '../shared/components/buttons/mixins' as buttons;
...@@ -25,3 +26,11 @@ ...@@ -25,3 +26,11 @@
} }
} }
} }
// This button style has asymmetrical padding. Hold it here to see if
// this kind of padding is useful in other patterns.
.PaginationPageButton {
@include buttons.LabeledButton {
padding: var.$layout-space--small var.$layout-space;
}
}
...@@ -26,31 +26,6 @@ ...@@ -26,31 +26,6 @@
display: none; display: none;
} }
&__button,
&__page-button {
@include buttons.button--labeled(
$background-color: transparent,
$active-background-color: var.$grey-3
);
}
&__page-button {
margin: var.$layout-space--xxsmall;
padding: var.$layout-space--small var.$layout-space;
&[aria-pressed='true'] {
background-color: var.$grey-3;
}
}
&__button-right {
// FIXME Button SVG margins assume that the icon is on the left
svg {
margin-left: var.$layout-space--xxsmall;
}
padding-right: var.$layout-space--xxsmall;
}
@include responsive.wide-handheld-and-up { @include responsive.wide-handheld-and-up {
// Where there's enough horizontal space, // Where there's enough horizontal space,
// lay out page navigation buttons horizontally as: // lay out page navigation buttons horizontally as:
...@@ -65,6 +40,7 @@ ...@@ -65,6 +40,7 @@
display: block; display: block;
grid-area: numberedPages; grid-area: numberedPages;
@include layout.row($justify: center, $align: center); @include layout.row($justify: center, $align: center);
@include layout.horizontal-rhythm(0.5em);
} }
} }
} }
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