Skip to content

Commit

Permalink
Use NoteBox component, and fix overflow detection
Browse files Browse the repository at this point in the history
  • Loading branch information
dmfalke committed Nov 15, 2024
1 parent 8e04c82 commit 8c7ffcc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import PropTypes from 'prop-types';
import React, { useState } from 'react';
import { safeHtml, wrappable } from '../../../Utils/ComponentUtils';

const containerStyle = {
display: 'flex',
flexWrap: 'wrap',
borderLeft: '.2em solid #79a3d7',
borderRight: '.2em solid #79a3d7',
padding: '.5em 1em',
background: '#ebf4ff',
gap: '1em',
marginBottom: '1em',
};
import { NoteBox } from '@veupathdb/coreui';

function RecordTableDescription(props) {
const { description } = props.table;
Expand All @@ -21,7 +11,7 @@ function RecordTableDescription(props) {
if (!description) return null;

return (
<div style={containerStyle}>
<NoteBox type="info">
{safeHtml(
description,
{
Expand All @@ -30,7 +20,7 @@ function RecordTableDescription(props) {
return;
}
if (
el.clientWidth >= el.scrollWidth ||
el.clientWidth >= el.scrollWidth &&
el.clientHeight >= el.scrollHeight
) {
setIsOverflowing(false);
Expand All @@ -51,15 +41,23 @@ function RecordTableDescription(props) {
'div'
)}
{isOverflowing && (
<button
type="button"
className="link"
onClick={() => setIsExpanded((value) => !value)}
>
{isExpanded ? 'Read less' : 'Read more'}
</button>
<>
<button
type="button"
style={{
border: 'none',
padding: 0,
margin: '1ex 0 0 0',
background: 'transparent',
color: '#069',
}}
onClick={() => setIsExpanded((value) => !value)}
>
{isExpanded ? 'Read less' : 'Read more'}
</button>
</>
)}
</div>
</NoteBox>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { PfamDomain } from 'ortho-client/components/pfam-domains/PfamDomain';
import {
FilledButton,
FloatingButton,
NoteBox,
OutlinedButton,
SelectList,
Undo,
Expand Down Expand Up @@ -662,23 +663,7 @@ export function RecordTable_Sequences(
} as CSSProperties
}
>
{warningText && (
<div
style={{
display: 'flex',
flexWrap: 'wrap',
borderLeft: '.2em solid rgb(225, 133, 133)',
borderRight: '.2em solid rgb(225, 133, 133)',
padding: '.5em 1em',
background: 'rgb(255, 228, 228)',
gap: '1em',
marginBottom: '1em',
fontWeight: 500,
}}
>
{warningText}
</div>
)}
{warningText && <NoteBox type="error">{warningText}</NoteBox>}
<div
style={{
padding: '10px',
Expand Down

0 comments on commit 8c7ffcc

Please sign in to comment.