Skip to content

Commit

Permalink
Don't use line clamping when there's nothing to clamp. Also inline ja…
Browse files Browse the repository at this point in the history
…strow line clamping logic to be only in JS
  • Loading branch information
ronshapiro committed Nov 11, 2024
1 parent 268246d commit 6e9cd88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
4 changes: 0 additions & 4 deletions css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,6 @@ html, body {

float: none;
}

.jastrow .english { /* commentaryKind.className */
-webkit-line-clamp: 3 !important;
}
.commentary_header {
text-decoration: underline;
display: inline-block;
Expand Down
21 changes: 15 additions & 6 deletions js/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ function TableRow(props: TableRowProps): React.ReactElement {
return {shouldWrap: false, englishLineClampLines: 1000000};
}

if (classes.includes("jastrow")) {
return {shouldWrap: false, englishLineClampLines: 3};
}

applyHiddenNode(hebrew, hiddenHost.hebrew);
applyHiddenNode(english, hiddenHost.english);

Expand Down Expand Up @@ -368,12 +372,12 @@ function TableRow(props: TableRowProps): React.ReactElement {
$(context.hiddenHost).width(), // recalculate only when there are changes in width
]);

const cellClasses = () => {
const cellClasses = (() => {
if ((isEmptyText(hebrew) || isEmptyText(english)) && !overrideFullRow) {
return ["fullRow"];
}
return [];
};
})();

const cells = [];
if (!isEmptyText(hebrew)) {
Expand All @@ -386,22 +390,27 @@ function TableRow(props: TableRowProps): React.ReactElement {
<HebrewCell
key="hebrew"
text={contents}
classes={cellClasses()}
classes={cellClasses}
hebrewDoubleClickListener={hebrewDoubleClickListener}
isEnglishExpanded={isEnglishExpanded}
shouldWrap={shouldWrap}
/>);
}
cells.push(<div className="text-selection-divider" key="text-selection-divider" />);
if (!isEmptyText(english)) {
const toggleEnglishExpanded = () => setIsEnglishExpanded(previousState => !previousState);
const [overrideExpandedEnglish, toggleEnglishExpanded] = (() => {
if (cellClasses.includes("fullRow") && !classes.includes("jastrow")) {
return [true, () => {}];
}
return [isEnglishExpanded, () => setIsEnglishExpanded(previousState => !previousState)];
})();
cells.push(
<EnglishCell
key="english"
text={english}
classes={cellClasses()}
classes={cellClasses}
toggleEnglishExpanded={toggleEnglishExpanded}
isEnglishExpanded={isEnglishExpanded}
isEnglishExpanded={overrideExpandedEnglish}
lineClampLines={englishLineClampLines}
shouldWrap={shouldWrap}
/>);
Expand Down

0 comments on commit 6e9cd88

Please sign in to comment.