Commit 5ce4ac3b authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Update shared components in `AnnotationBody`

Visual change: font in button to expand and collapse excerpt is now
semi-bold, which matches all of our other buttons.
parent f5ed2b90
import { Icon, LabeledButton } from '@hypothesis/frontend-shared'; import {
Button,
CollapseIcon,
ExpandIcon,
} from '@hypothesis/frontend-shared/lib/next';
import classnames from 'classnames'; import classnames from 'classnames';
import { useMemo, useState } from 'preact/hooks'; import { useMemo, useState } from 'preact/hooks';
...@@ -29,25 +33,21 @@ import TagListItem from '../TagListItem'; ...@@ -29,25 +33,21 @@ import TagListItem from '../TagListItem';
function ToggleExcerptButton({ classes, setCollapsed, collapsed }) { function ToggleExcerptButton({ classes, setCollapsed, collapsed }) {
const toggleText = collapsed ? 'More' : 'Less'; const toggleText = collapsed ? 'More' : 'Less';
return ( return (
<LabeledButton <Button
classes={classnames('text-grey-7 font-normal', classes)} classes={classnames('text-grey-7 font-normal', classes)}
expanded={!collapsed} expanded={!collapsed}
onClick={() => setCollapsed(!collapsed)} onClick={() => setCollapsed(!collapsed)}
title={`Toggle visibility of full annotation text: Show ${toggleText}`} title={`Toggle visibility of full annotation text: Show ${toggleText}`}
> >
<div className="flex items-center gap-x-2"> <div className="flex items-center gap-x-2">
<Icon {collapsed ? (
classes={classnames( <ExpandIcon className="w-3 h-3" />
// TODO: Refactor shared LabeledButton styles such that rules ) : (
// have lower specificity and we don't need an !important rule here <CollapseIcon className="w-3 h-3" />
'!text-tiny'
)} )}
name={collapsed ? 'expand' : 'collapse'}
title={collapsed ? 'expand' : 'collapse'}
/>
<div>{toggleText}</div> <div>{toggleText}</div>
</div> </div>
</LabeledButton> </Button>
); );
} }
......
...@@ -125,7 +125,7 @@ describe('AnnotationBody', () => { ...@@ -125,7 +125,7 @@ describe('AnnotationBody', () => {
}); });
wrapper.update(); wrapper.update();
const button = wrapper.find('LabeledButton'); const button = wrapper.find('Button');
assert.isOk(button.exists()); assert.isOk(button.exists());
assert.equal( assert.equal(
button.props().title, button.props().title,
...@@ -146,11 +146,11 @@ describe('AnnotationBody', () => { ...@@ -146,11 +146,11 @@ describe('AnnotationBody', () => {
wrapper.update(); wrapper.update();
act(() => { act(() => {
wrapper.find('LabeledButton').props().onClick(); wrapper.find('Button').props().onClick();
}); });
wrapper.update(); wrapper.update();
const buttonProps = wrapper.find('LabeledButton').props(); const buttonProps = wrapper.find('Button').props();
assert.equal( assert.equal(
buttonProps.title, buttonProps.title,
......
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