Commit c626631c authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Define utilities layer and remove local utility CSS classes

Replace use of local utility classes with tailwind
utility classes that do the same thing. Structure the utilities
layer for both sidebar and annotator.
parent c9d83949
...@@ -109,7 +109,7 @@ function AnnotationActionBar({ ...@@ -109,7 +109,7 @@ function AnnotationActionBar({
}; };
return ( return (
<div className="AnnotationActionBar hyp-u-layout-row u-font--xlarge"> <div className="AnnotationActionBar hyp-u-layout-row text-xl font-medium">
{showEditAction && ( {showEditAction && (
<IconButton icon="edit" title="Edit" onClick={onEdit} /> <IconButton icon="edit" title="Edit" onClick={onEdit} />
)} )}
......
...@@ -16,7 +16,7 @@ import { Link } from '@hypothesis/frontend-shared'; ...@@ -16,7 +16,7 @@ import { Link } from '@hypothesis/frontend-shared';
export default function AnnotationDocumentInfo({ domain, link, title }) { export default function AnnotationDocumentInfo({ domain, link, title }) {
return ( return (
<div className="hyp-u-layout-row hyp-u-horizontal-spacing--2"> <div className="hyp-u-layout-row hyp-u-horizontal-spacing--2">
<div className="u-color-text--muted"> <div className="text-color-text-light">
on &quot; on &quot;
{link ? ( {link ? (
<Link href={link} target="_blank"> <Link href={link} target="_blank">
...@@ -27,7 +27,7 @@ export default function AnnotationDocumentInfo({ domain, link, title }) { ...@@ -27,7 +27,7 @@ export default function AnnotationDocumentInfo({ domain, link, title }) {
)} )}
&quot; &quot;
</div> </div>
{domain && <span className="u-color-text--muted">({domain})</span>} {domain && <span className="text-color-text-light">({domain})</span>}
</div> </div>
); );
} }
...@@ -115,10 +115,10 @@ function AnnotationHeader({ ...@@ -115,10 +115,10 @@ function AnnotationHeader({
return ( return (
<header> <header>
<div className="hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 u-wrap-reverse"> <div className="hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 flex-wrap-reverse">
{annotationIsPrivate && !isEditing && ( {annotationIsPrivate && !isEditing && (
<Icon <Icon
classes="u-icon--xsmall" classes="text-tiny"
name="lock" name="lock"
title="This annotation is visible only to you" title="This annotation is visible only to you"
/> />
...@@ -146,13 +146,13 @@ function AnnotationHeader({ ...@@ -146,13 +146,13 @@ function AnnotationHeader({
</div> </div>
{showExtendedInfo && ( {showExtendedInfo && (
<div className="hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 u-wrap-reverse"> <div className="hyp-u-layout-row--align-baseline hyp-u-horizontal-spacing--2 flex-wrap-reverse">
<AnnotationShareInfo annotation={annotation} /> <AnnotationShareInfo annotation={annotation} />
{!isEditing && isHighlight(annotation) && ( {!isEditing && isHighlight(annotation) && (
<Icon <Icon
name="highlight" name="highlight"
title="This is a highlight. Click 'edit' to add a note or tag." title="This is a highlight. Click 'edit' to add a note or tag."
classes="u-icon--xsmall u-color-text--muted" classes="text-tiny text-color-text-light"
/> />
)} )}
{showDocumentInfo && ( {showDocumentInfo && (
......
...@@ -5,15 +5,15 @@ import { Icon, Link } from '@hypothesis/frontend-shared'; ...@@ -5,15 +5,15 @@ import { Icon, Link } from '@hypothesis/frontend-shared';
*/ */
export default function AnnotationLicense() { export default function AnnotationLicense() {
return ( return (
<div className="hyp-u-padding--top hyp-u-border--top u-font--small u-line-height"> <div className="hyp-u-padding--top hyp-u-border--top text-sm leading-none">
<Link <Link
classes="hyp-u-layout-row--align-center p-link--muted" classes="hyp-u-layout-row--align-center p-link--muted"
href="http://creativecommons.org/publicdomain/zero/1.0/" href="http://creativecommons.org/publicdomain/zero/1.0/"
target="_blank" target="_blank"
title="View more information about the Creative Commons Public Domain dedication" title="View more information about the Creative Commons Public Domain dedication"
> >
<Icon name="cc-std" classes="u-icon--xsmall" /> <Icon name="cc-std" classes="text-tiny" />
<Icon name="cc-zero" classes="hyp-u-margin--left--1 u-icon--xsmall" /> <Icon name="cc-zero" classes="hyp-u-margin--left--1 text-tiny" />
<div className="hyp-u-margin--left--2"> <div className="hyp-u-margin--left--2">
Annotations can be freely reused by anyone for any purpose. Annotations can be freely reused by anyone for any purpose.
</div> </div>
......
...@@ -73,7 +73,7 @@ function AnnotationPublishControl({ ...@@ -73,7 +73,7 @@ function AnnotationPublishControl({
const menuLabel = ( const menuLabel = (
<div className="annotation-publish-button__menu-label" style={buttonStyle}> <div className="annotation-publish-button__menu-label" style={buttonStyle}>
<Icon name="expand-menu" classes="u-icon--small" /> <Icon name="expand-menu" />
</div> </div>
); );
......
...@@ -37,15 +37,15 @@ function AnnotationShareInfo({ annotation }) { ...@@ -37,15 +37,15 @@ function AnnotationShareInfo({ annotation }) {
target="_blank" target="_blank"
> >
{group.type === 'open' ? ( {group.type === 'open' ? (
<Icon classes="u-icon--xsmall" name="public" /> <Icon classes="text-tiny" name="public" />
) : ( ) : (
<Icon classes="u-icon--xsmall" name="groups" /> <Icon classes="text-tiny" name="groups" />
)} )}
<span>{group.name}</span> <span>{group.name}</span>
</Link> </Link>
)} )}
{annotationIsPrivate && !linkToGroup && ( {annotationIsPrivate && !linkToGroup && (
<span className="hyp-u-layout-row--align-baseline u-color-text--muted"> <span className="hyp-u-layout-row--align-baseline text-color-text-light">
<span data-testid="private-info">Only me</span> <span data-testid="private-info">Only me</span>
</span> </span>
)} )}
......
...@@ -81,7 +81,7 @@ export default function AnnotationTimestamps({ ...@@ -81,7 +81,7 @@ export default function AnnotationTimestamps({
<div> <div>
{withEditedTimestamp && ( {withEditedTimestamp && (
<span <span
className="u-color-text--muted u-font--small u-font--italic" className="text-color-text-light text-sm italic"
data-testid="timestamp-edited" data-testid="timestamp-edited"
title={updated.absolute} title={updated.absolute}
> >
...@@ -99,7 +99,7 @@ export default function AnnotationTimestamps({ ...@@ -99,7 +99,7 @@ export default function AnnotationTimestamps({
</Link> </Link>
) : ( ) : (
<span <span
className="u-color-text--muted" className="color-text-color-light"
data-testid="timestamp-created" data-testid="timestamp-created"
title={created.absolute} title={created.absolute}
> >
......
...@@ -13,7 +13,7 @@ import { Link } from '@hypothesis/frontend-shared'; ...@@ -13,7 +13,7 @@ import { Link } from '@hypothesis/frontend-shared';
* @param {AnnotationUserProps} props * @param {AnnotationUserProps} props
*/ */
function AnnotationUser({ authorLink, displayName }) { function AnnotationUser({ authorLink, displayName }) {
const user = <h3 className="u-color-text u-font--bold">{displayName}</h3>; const user = <h3 className="text-color-text font-bold">{displayName}</h3>;
if (authorLink) { if (authorLink) {
return ( return (
......
...@@ -36,9 +36,7 @@ function FilterSelect({ ...@@ -36,9 +36,7 @@ function FilterSelect({
const menuLabel = ( const menuLabel = (
<span className="FilterSelect__menu-label"> <span className="FilterSelect__menu-label">
{icon && ( {icon && <Icon name={icon} classes="text-xl hyp-u-margin--right--3" />}
<Icon name={icon} classes="u-icon--medium hyp-u-margin--right--3" />
)}
{selected.display} {selected.display}
</span> </span>
); );
......
...@@ -46,7 +46,7 @@ function LoggedOutMessage({ onLogin }) { ...@@ -46,7 +46,7 @@ function LoggedOutMessage({ onLogin }) {
aria-label="Hypothesis homepage" aria-label="Hypothesis homepage"
title="Hypothesis homepage" title="Hypothesis homepage"
> >
<Icon name="logo" classes="u-icon--xlarge hyp-u-color--grey-7" /> <Icon name="logo" classes="w-16 h-16 hyp-u-color--grey-7" />
</a> </a>
</div> </div>
</div> </div>
......
...@@ -138,10 +138,7 @@ function ToolbarButton({ ...@@ -138,10 +138,7 @@ function ToolbarButton({
if (label) { if (label) {
return ( return (
<LabeledButton <LabeledButton classes="font-normal TransparentButton" {...buttonProps}>
classes="u-font--normal TransparentButton"
{...buttonProps}
>
{label} {label}
</LabeledButton> </LabeledButton>
); );
...@@ -353,7 +350,7 @@ function Toolbar({ isPreviewing, onCommand, onTogglePreview }) { ...@@ -353,7 +350,7 @@ function Toolbar({ isPreviewing, onCommand, onTogglePreview }) {
<Link <Link
href="https://web.hypothes.is/help/formatting-annotations-with-markdown/" href="https://web.hypothes.is/help/formatting-annotations-with-markdown/"
target="_blank" target="_blank"
classes="u-font--xsmall IconOnlyLink" classes="text-tiny IconOnlyLink"
linkRef={buttonRefs[buttonIds.help]} linkRef={buttonRefs[buttonIds.help]}
tabIndex={getTabIndex(buttonIds.help)} tabIndex={getTabIndex(buttonIds.help)}
title="Formatting help" title="Formatting help"
...@@ -430,7 +427,7 @@ export default function MarkdownEditor({ ...@@ -430,7 +427,7 @@ export default function MarkdownEditor({
}; };
return ( return (
<div className="u-line-height"> <div className="leading-none">
<Toolbar <Toolbar
onCommand={handleCommand} onCommand={handleCommand}
isPreviewing={preview} isPreviewing={preview}
......
...@@ -133,7 +133,7 @@ function NotebookView({ loadAnnotationsService, streamer }) { ...@@ -133,7 +133,7 @@ function NotebookView({ loadAnnotationsService, streamer }) {
<div className="NotebookView__filters"> <div className="NotebookView__filters">
<NotebookFilters /> <NotebookFilters />
</div> </div>
<div className="NotebookView__results hyp-u-layout-row--align-center u-font--large"> <div className="NotebookView__results hyp-u-layout-row--align-center text-lg font-medium">
{pendingUpdateCount > 0 && !hasAppliedFilter && ( {pendingUpdateCount > 0 && !hasAppliedFilter && (
<IconButton <IconButton
icon="refresh" icon="refresh"
......
...@@ -45,7 +45,7 @@ function Tab({ ...@@ -45,7 +45,7 @@ function Tab({
return ( return (
<LabeledButton <LabeledButton
classes={classnames('u-color-text', 'SelectionTab', { classes={classnames('text-color-text', 'SelectionTab', {
'is-selected': isSelected, 'is-selected': isSelected,
})} })}
// Listen for `onMouseDown` so that the tab is selected when _pressed_ // Listen for `onMouseDown` so that the tab is selected when _pressed_
...@@ -62,7 +62,7 @@ function Tab({ ...@@ -62,7 +62,7 @@ function Tab({
{children} {children}
{count > 0 && !isWaitingToAnchor && ( {count > 0 && !isWaitingToAnchor && (
<span <span
className="u-font--xsmall" className="text-tiny"
style="position:relative;bottom:3px;left:2px" style="position:relative;bottom:3px;left:2px"
> >
{count} {count}
...@@ -158,14 +158,14 @@ function SelectionTabs({ annotationsService, isLoading, settings }) { ...@@ -158,14 +158,14 @@ function SelectionTabs({ annotationsService, isLoading, settings }) {
</div> </div>
)} )}
{!isLoading && showNotesUnavailableMessage && ( {!isLoading && showNotesUnavailableMessage && (
<Frame classes="u-text--centered"> <Frame classes="text-center">
<span data-testid="notes-unavailable-message"> <span data-testid="notes-unavailable-message">
There are no page notes in this group. There are no page notes in this group.
</span> </span>
</Frame> </Frame>
)} )}
{!isLoading && showAnnotationsUnavailableMessage && ( {!isLoading && showAnnotationsUnavailableMessage && (
<Frame classes="u-text--centered"> <Frame classes="text-center">
<span data-testid="annotations-unavailable-message"> <span data-testid="annotations-unavailable-message">
There are no annotations in this group. There are no annotations in this group.
<br /> <br />
......
...@@ -40,7 +40,7 @@ export default function SidebarContentError({ ...@@ -40,7 +40,7 @@ export default function SidebarContentError({
})(); })();
return ( return (
<div className="u-sidebar-container"> <div className="mb-4">
<Panel icon="restricted" title={errorTitle}> <Panel icon="restricted" title={errorTitle}>
<p>{errorMessage}</p> <p>{errorMessage}</p>
<div className="hyp-u-layout-row--justify-right hyp-u-horizontal-spacing"> <div className="hyp-u-layout-row--justify-right hyp-u-horizontal-spacing">
......
...@@ -60,7 +60,7 @@ export default function SidebarPanel({ ...@@ -60,7 +60,7 @@ export default function SidebarPanel({
return ( return (
<Slider visible={panelIsActive}> <Slider visible={panelIsActive}>
<div ref={panelElement} className="u-sidebar-container"> <div ref={panelElement} className="mb-4">
<Panel title={title} icon={icon} onClose={closePanel}> <Panel title={title} icon={icon} onClose={closePanel}>
{children} {children}
</Panel> </Panel>
......
...@@ -142,7 +142,7 @@ function SidebarView({ ...@@ -142,7 +142,7 @@ function SidebarView({
return ( return (
<div> <div>
<h2 className="u-screen-reader-only">Annotations</h2> <h2 className="sr-only">Annotations</h2>
{showFilterStatus && <FilterStatus />} {showFilterStatus && <FilterStatus />}
<LoginPromptPanel onLogin={onLogin} onSignUp={onSignUp} /> <LoginPromptPanel onLogin={onLogin} onSignUp={onSignUp} />
{hasDirectLinkedAnnotationError && ( {hasDirectLinkedAnnotationError && (
......
...@@ -82,7 +82,7 @@ function TopBar({ ...@@ -82,7 +82,7 @@ function TopBar({
<span className="TopBar__login-links"></span> <span className="TopBar__login-links"></span>
)} )}
{auth.status === 'logged-out' && ( {auth.status === 'logged-out' && (
<span className="TopBar__login-links u-font--large hyp-u-horizontal-spacing--2"> <span className="TopBar__login-links text-lg font-medium hyp-u-horizontal-spacing--2">
<LinkButton <LinkButton
classes="InlineLinkButton" classes="InlineLinkButton"
onClick={onSignUp} onClick={onSignUp}
......
@use '@hypothesis/frontend-shared/styles/util';
@use 'tailwindcss/utilities';
...@@ -24,10 +24,7 @@ ...@@ -24,10 +24,7 @@
@use './components/Toolbar'; @use './components/Toolbar';
@use './components/WarningBanner'; @use './components/WarningBanner';
// Make the shared package utility styles available @use './utilities';
@use '@hypothesis/frontend-shared/styles/util';
@use 'tailwindcss/utilities';
// Styles for all top-level elements in shadow roots. // Styles for all top-level elements in shadow roots.
:host > * { :host > * {
......
@use '@hypothesis/frontend-shared/styles/util';
@use 'tailwindcss/utilities';
...@@ -44,9 +44,4 @@ ...@@ -44,9 +44,4 @@
@use './components/TopBar'; @use './components/TopBar';
@use './components/VersionInfo'; @use './components/VersionInfo';
// Make the shared package utility styles available @use './utilities';
@use '@hypothesis/frontend-shared/styles/util' as hyp-u;
// Local utility classes
@use '../util';
@use 'tailwindcss/utilities';
@use './mixins/a11y';
@use './mixins/utils';
@use './variables' as var;
// Utility classes
// These will be extracted and considered when developing typography patterns
.u-font--xsmall {
font-size: 10px;
}
.u-font--small {
@include utils.font--small;
}
.u-font--large {
@include utils.font--large;
}
.u-font--xlarge {
@include utils.font--xlarge;
}
.u-font--bold {
font-weight: bold;
}
.u-font--italic {
font-style: italic;
}
.u-font--normal {
font-weight: normal;
}
.u-line-height {
line-height: 1;
}
// Icons
// These utilities establish dimensions appropriate for icon elements
// Use for inline icons to size according to text content
.u-icon--inline {
@include utils.icon--inline;
}
.u-icon--xsmall {
@include utils.icon--xsmall;
}
.u-icon--small {
@include utils.icon--small;
}
.u-icon--medium {
@include utils.icon--medium;
}
.u-icon--large {
@include utils.icon--large;
}
.u-icon--xlarge {
width: 30px;
height: 30px;
}
// Misc
// Make element content invisible except to assistive technology
.u-screen-reader-only {
@include a11y.screen-reader-only;
}
// Use on elements for a de-emphasized, muted text color
.u-color-text--muted {
color: var.$color-text--light;
}
.u-color-text {
color: var.$color-text;
}
// Layout
.u-inline {
display: inline;
}
.u-text--centered {
text-align: center;
}
// A style to make a flex row wrap from bottom to top instead of (default)
// top to bottom
.u-wrap-reverse {
flex-wrap: wrap-reverse;
}
// TODO: This is a temporary utility class to allow elements in the sidebar
// (e.g. panels, thread cards, etc.)
// to apply margins such that they are evenly spaced. In the future, the
// sidebar markup (DOM structure) should be reorganized and consolidated such
// that is possible to apply vertical-spacing rules to the sidebar container
// (these rules set margins on immediate-child elements).
// This class should be removed once patterns are available for vertical spacing
// and the sidebar element structure can be adjusted.
.u-sidebar-container {
margin-bottom: 1em;
}
...@@ -11,10 +11,11 @@ export default { ...@@ -11,10 +11,11 @@ export default {
theme: { theme: {
extend: { extend: {
borderColor: { borderColor: {
DEFAULT: '#dbdbdb', DEFAULT: '#dbdbdb', // TODO: remove when available from upstream preset
}, },
colors: { colors: {
'color-text': { 'color-text': {
// TODO: remove when available from upstream preset
DEFAULT: '#202020', DEFAULT: '#202020',
light: '#737373', light: '#737373',
}, },
...@@ -28,9 +29,15 @@ export default { ...@@ -28,9 +29,15 @@ export default {
'sans-serif', 'sans-serif',
], ],
}, },
// The following text sizes describe the current font sizes being used
// in the app (descriptive), but should not be interpreted as defining
// an ideal design system (prescriptive).
fontSize: { fontSize: {
tiny: ['10px'],
sm: ['11px', '1.4'],
base: ['13px', '1.4'], base: ['13px', '1.4'],
lg: ['14px'], lg: ['14px'],
xl: ['16px'],
}, },
}, },
}, },
......
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