Skip to content

Commit 53cfa59

Browse files
committed
Let each hover trigger decide bold vs not, share one style with default cursor
HOVER_BTN_STYLE is now a single constant (default cursor, no bold) used directly everywhere; bold is merged in per instance instead of being baked into per-file variants. Triggers naming a specific result value (District N, N election(s)) stay bold; triggers introducing or explaining a concept (Freedom-To-Vote test, the 4 recent statewide elections) don't. The wrap fix for the one long trigger phrase moves to its own WRAPPING_HOVER_BTN_STYLE, layered on the shared base.
1 parent 2d821d2 commit 53cfa59

3 files changed

Lines changed: 18 additions & 25 deletions

File tree

app/src/app/components/EvalPanel/BasicsSection.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {useMapStore} from '@store/mapStore';
88
import {DocumentEvaluation} from '@utils/api/apiHandlers/getEvaluation';
99
import {useDistrictHover} from '@/app/hooks/useDistrictHover';
1010
import {useZoomToDistrict} from '@/app/hooks/useZoomToDistrict';
11-
import {HOVER_TRIGGER_BASE_STYLE} from './hoverTriggerStyle';
11+
import {HOVER_BTN_STYLE} from './hoverTriggerStyle';
1212

1313
type DeviationView = 'top_to_bottom' | 'max_absolute' | 'both';
1414

@@ -23,12 +23,6 @@ interface BasicsSectionProps {
2323
evaluation: DocumentEvaluation;
2424
}
2525

26-
const HOVER_BTN_STYLE: React.CSSProperties = {
27-
...HOVER_TRIGGER_BASE_STYLE,
28-
fontWeight: 'bold',
29-
cursor: 'default',
30-
};
31-
3226
export const BasicsSection: React.FC<BasicsSectionProps> = ({evaluation}) => {
3327
const mapDocument = useMapStore(state => state.mapDocument);
3428
const {onDistrictEnter, onDistrictLeave} = useDistrictHover();
@@ -189,7 +183,7 @@ export const BasicsSection: React.FC<BasicsSectionProps> = ({evaluation}) => {
189183
Your plan&apos;s most populous district is{' '}
190184
<button
191185
type="button"
192-
style={HOVER_BTN_STYLE}
186+
style={{...HOVER_BTN_STYLE, fontWeight: 'bold'}}
193187
onMouseEnter={() => onDistrictEnter(population_deviation.most_populous_district)}
194188
onMouseLeave={onDistrictLeave}
195189
onFocus={() => onDistrictEnter(population_deviation.most_populous_district)}
@@ -200,7 +194,7 @@ export const BasicsSection: React.FC<BasicsSectionProps> = ({evaluation}) => {
200194
and least populous district is{' '}
201195
<button
202196
type="button"
203-
style={HOVER_BTN_STYLE}
197+
style={{...HOVER_BTN_STYLE, fontWeight: 'bold'}}
204198
onMouseEnter={() => onDistrictEnter(population_deviation.least_populous_district)}
205199
onMouseLeave={onDistrictLeave}
206200
onFocus={() => onDistrictEnter(population_deviation.least_populous_district)}

app/src/app/components/EvalPanel/PartisanSection.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {NUMBER_FORMATS} from '@/app/constants/demography/format';
1010
import {PovSwitcher, type Pov} from '@components/Shared/PovSwitcher';
1111
import {getReadableTextColor} from '@/app/utils/colors';
1212
import {HelpTip, HELP_TIP_FAST_DELAY} from '@components/HelpTip/HelpTip';
13-
import {HOVER_TRIGGER_BASE_STYLE} from './hoverTriggerStyle';
13+
import {HOVER_BTN_STYLE} from './hoverTriggerStyle';
1414

1515
interface PartisanSectionProps {
1616
evaluation: DocumentEvaluation;
@@ -39,14 +39,11 @@ const METRIC_CUTOFF = {
3939

4040
const MAX_ALPHA = 0.6;
4141

42-
// Used for both the FTV HelpTip trigger and the "4 recent statewide elections"
43-
// cross-table highlight trigger.
44-
const HOVER_BTN_STYLE: React.CSSProperties = {
45-
...HOVER_TRIGGER_BASE_STYLE,
46-
cursor: 'help',
47-
// Overrides the browser default button style (inline-block, nowrap) so a
48-
// multi-word trigger like "the 4 recent statewide elections" wraps with the
49-
// surrounding paragraph instead of staying on one line.
42+
// Overrides the browser default button style (inline-block, nowrap) so a
43+
// multi-word trigger like "the 4 recent statewide elections" wraps with the
44+
// surrounding paragraph instead of staying on one line.
45+
const WRAPPING_HOVER_BTN_STYLE: React.CSSProperties = {
46+
...HOVER_BTN_STYLE,
5047
display: 'inline',
5148
whiteSpace: 'normal',
5249
};
@@ -340,7 +337,7 @@ export const PartisanSection: React.FC<PartisanSectionProps> = ({evaluation}) =>
340337
: among{' '}
341338
<button
342339
type="button"
343-
style={HOVER_BTN_STYLE}
340+
style={WRAPPING_HOVER_BTN_STYLE}
344341
onMouseEnter={() => setFtvHover(true)}
345342
onMouseLeave={() => setFtvHover(false)}
346343
onFocus={() => setFtvHover(true)}
@@ -352,7 +349,7 @@ export const PartisanSection: React.FC<PartisanSectionProps> = ({evaluation}) =>
352349
out of {numDistricts} seats for{' '}
353350
<button
354351
type="button"
355-
style={HOVER_BTN_STYLE}
352+
style={{...HOVER_BTN_STYLE, fontWeight: 'bold'}}
356353
onMouseEnter={() => setFtvPassHover(true)}
357354
onMouseLeave={() => setFtvPassHover(false)}
358355
onFocus={() => setFtvPassHover(true)}
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import type {CSSProperties} from 'react';
22

3-
/** Shared base for an inline, underlined-dotted hover trigger that reads as plain
4-
* text until hovered — used by BasicsSection (district-highlight triggers) and
5-
* PartisanSection (FTV HelpTip and table-highlight triggers). Each caller layers
6-
* its own `cursor`/`fontWeight`/wrap overrides on top for its own use case. */
7-
export const HOVER_TRIGGER_BASE_STYLE: CSSProperties = {
3+
/** Shared inline, underlined-dotted hover trigger style, used by BasicsSection
4+
* (district-highlight triggers) and PartisanSection (FTV HelpTip and
5+
* table-highlight triggers). `fontWeight`/wrap behavior are layered on top per
6+
* usage — a trigger naming a specific result value reads bold, one introducing
7+
* or explaining a concept doesn't. */
8+
export const HOVER_BTN_STYLE: CSSProperties = {
89
background: 'none',
910
border: 'none',
1011
padding: 0,
1112
font: 'inherit',
13+
cursor: 'default',
1214
textDecoration: 'underline dotted',
1315
};

0 commit comments

Comments
 (0)