Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/js/components/Drawers/HeaderProfileDrawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,10 @@ function HeaderProfileDrawer () {
)}
<YourAccountWrapper>
<AccountCircleStyled />
<div>Your Settings</div>
<div>
<span className="u-show-mobile">Settings</span>
<span className="u-show-desktop-tablet">Your&nbsp;Settings</span>
</div>
</YourAccountWrapper>
{windowWidth >= 768 && (
<>
Expand Down Expand Up @@ -288,7 +291,7 @@ function HeaderProfileDrawer () {
<>
{showLinksToProfilePages ? (
<NavLinksContainer>
{ImportContactsJsx}
{nextReleaseFeaturesEnabled && ImportContactsJsx}
{linksToProfilePages}
{SignOutJsx}
<SettingsSectionFooterWrapper>
Expand All @@ -302,7 +305,7 @@ function HeaderProfileDrawer () {
) : (
<>
<NavLinksContainer>
{ImportContactsJsx}
{nextReleaseFeaturesEnabled && ImportContactsJsx}
{linksToProfilePages}
{SignOutJsx}
<SettingsSectionFooterWrapper>
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Navigation/SettingsPersonalSideBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default class SettingsPersonalSideBar extends Component {
<div className="card-main">
<div className="SettingsItem__summary__title">Your Settings</div>

{isSignedIn && nextReleaseFeaturesEnabled && (
{(isSignedIn && nextReleaseFeaturesEnabled) && (
<div className={String(editMode) === 'contacts' ?
'SettingsItem__summary__item-container SettingsItem__summary__item-container--selected' :
'SettingsItem__summary__item-container '}
Expand Down
5 changes: 2 additions & 3 deletions src/js/components/Widgets/ItemActionBar/ItemActionBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ import SupportStore from '../../../stores/SupportStore';
import VoterStore from '../../../stores/VoterStore';
import { possibleAppReview } from '../../../utils/appReviewFunctions';
import lookupPageNameAndPageTypeDict, { getPageDetails } from '../../../utils/lookupPageNameAndPageTypeDict';
import PositionPublicToggle from '../../PositionItem/PositionPublicToggle';
// import PositionPublicToggle from '../../PositionItem/PositionPublicToggle';
import ReviewAppModal from '../../ReviewApps/ReviewAppModal';
import PositionStatementModal from '../PositionStatementModal'; // eslint-disable-line import/no-cycle
import ShareButtonDropDown from '../ShareButtonDropdown';
import MakePublicVisibilityRow from './MakePublicVisibilityRow';

const HelpWinOrDefeatModal = React.lazy(() => import(/* webpackChunkName: 'HelpWinOrDefeatModal' */ '../../../common/components/CampaignSupport/HelpWinOrDefeatModal')); // eslint-disable-line import/no-cycle
const nextReleaseFeaturesEnabled = webAppConfig.ENABLE_NEXT_RELEASE_FEATURES === undefined ? false : webAppConfig.ENABLE_NEXT_RELEASE_FEATURES;

const NUMBER_OF_BALLOT_CHOICES_ALLOWED_BEFORE_SHOW_MODAL = 3;
const shareIconSvg = '../../../../img/global/svg-icons/share-icon.svg';
Expand Down Expand Up @@ -1102,7 +1101,7 @@ class ItemActionBar extends PureComponent {

{/* Chat bubble + "For candidate staff", candidates/politicians only.
Pass showCandidateStaffAndChat prop to enable (e.g. in BallotScrollingContainer). */}
{((ballotItemType === 'CANDIDATE' || ballotItemType === 'POLITICIAN') && this.props.showCandidateStaffAndChat && nextReleaseFeaturesEnabled) && (
{((ballotItemType === 'CANDIDATE' || ballotItemType === 'POLITICIAN') && this.props.showCandidateStaffAndChat) && (
<>
{/* When visibilityRowOpen: hide bubble, show divider + visibility text inline */}
{visibilityRowOpen ? (
Expand Down
39 changes: 31 additions & 8 deletions src/js/pages/ElectionFinder/ElectionFinderForElection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ import {
CandidateParty, CandidateRow, DetailTitle, ElectionTitleRow,
ExpandCollapseButton, ExpandCollapseRow, ExpandMoreIcon,
HighlightSpan, InlineSearchField, NoResults,
OfficeHeader, OfficeHeaderActions, OfficeHeaderLeft, OfficeName,
OfficeHeader, OfficeHeaderActions, OfficeHeaderLeft, OfficeName, OfficePrimaryPartySpan,
OfficeSection, SearchIconButton, SearchResultCount, ShowMoreButton,
} from './electionFinderStyles';
import webAppConfig from '../../config';

const nextReleaseFeaturesEnabled = webAppConfig.ENABLE_NEXT_RELEASE_FEATURES === undefined ? false : webAppConfig.ENABLE_NEXT_RELEASE_FEATURES;

function ElectionFinderForElection () {
renderLog('ElectionFinderForElection');
Expand Down Expand Up @@ -205,9 +208,11 @@ function ElectionFinderForElection () {

<ElectionTitleRow>
<DetailTitle>{electionName}</DetailTitle>
<DarkTooltip title="Download election data">
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
{nextReleaseFeaturesEnabled && (
<DarkTooltip title="Download election data">
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
)}
{electionSearchOpen ? (
<InlineSearchField
variant="outlined"
Expand Down Expand Up @@ -306,9 +311,25 @@ function OfficeSectionItemInner ({ // eslint-disable-line react/no-multi-comp
office, isExpanded, searchText,
onToggle, onCandidateClick, getCandidatePath, copyToClipboard, highlightMatch,
}) {
// console.log('OfficeSectionItemInner render office: ', office);
const officeWeVoteId = office.we_vote_id;
const officeName = office.ballot_item_display_name;
const primaryParty = office.primary_party || '';
const candidates = office.candidate_list || [];
const officeNameWithPrimaryParty = (
<span>
{officeName}
{primaryParty && (
<OfficePrimaryPartySpan>
,
{' '}
{primaryParty}
{' '}
Primary
</OfficePrimaryPartySpan>
)}
</span>
);
return (
<OfficeSection>
<OfficeHeader onClick={() => onToggle(officeWeVoteId)}>
Expand All @@ -317,7 +338,7 @@ function OfficeSectionItemInner ({ // eslint-disable-line react/no-multi-comp
<ExpandMore fontSize="small" />
</ExpandMoreIcon>
<OfficeName>
{searchText ? highlightMatch(officeName, searchText) : officeName}
{searchText ? highlightMatch(officeNameWithPrimaryParty, searchText) : officeNameWithPrimaryParty}
{` (${candidates.length})`}
</OfficeName>
</OfficeHeaderLeft>
Expand All @@ -335,9 +356,11 @@ function OfficeSectionItemInner ({ // eslint-disable-line react/no-multi-comp
</ActionChip>
</DarkTooltip>
<ActionDivider />
<DarkTooltip title="Info">
<IconButton size="small"><InfoOutlined fontSize="small" /></IconButton>
</DarkTooltip>
{nextReleaseFeaturesEnabled && (
<DarkTooltip title="Info">
<IconButton size="small"><InfoOutlined fontSize="small" /></IconButton>
</DarkTooltip>
)}
<DarkTooltip title="Open in new tab">
<IconButton size="small" onClick={() => window.open(`/office/${officeWeVoteId}`, '_blank')}>
<Launch fontSize="small" />
Expand Down
19 changes: 13 additions & 6 deletions src/js/pages/ElectionFinder/ElectionFinderForState.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import {
SearchIconButton, SectionTitle, SectionTitleRow, ShowMoreButton,
StateSelectWrapper, StateSelectNative, StateSelectLabel, StateSelectCaret,
} from './electionFinderStyles';
import webAppConfig from '../../config';

const nextReleaseFeaturesEnabled = webAppConfig.ENABLE_NEXT_RELEASE_FEATURES === undefined ? false : webAppConfig.ENABLE_NEXT_RELEASE_FEATURES;

const SORTED_STATES = Object.entries(stateCodeMap)
.filter(([code]) => code !== 'NA')
Expand Down Expand Up @@ -216,9 +219,11 @@ function ElectionFinderForState () {

<SectionTitleRow>
<SectionTitle>{sectionTitle}</SectionTitle>
<DarkTooltip title={sectionDownloadLabel}>
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
{nextReleaseFeaturesEnabled && (
<DarkTooltip title={sectionDownloadLabel}>
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
)}
</SectionTitleRow>

<ElectionList>
Expand All @@ -245,9 +250,11 @@ function ElectionFinderForState () {
</ActionChip>
</DarkTooltip>
<ActionDivider />
<DarkTooltip title="Download election data">
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
{nextReleaseFeaturesEnabled && (
<DarkTooltip title="Download election data">
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
)}
<DarkTooltip title="Open in new tab">
<IconButton size="small" onClick={() => window.open(`/election-finder/${selectedStateCode.toLowerCase()}/${googleCivicElectionId}`, '_blank')}>
<Launch fontSize="small" />
Expand Down
2 changes: 1 addition & 1 deletion src/js/pages/ElectionFinder/ElectionFinderHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function ElectionFinderHeader ({ breadcrumbs, stateLabel, subtitle }) {
{isLast || !crumb.href ? (
<span>{crumb.label}</span>
) : (
<BreadcrumbAnchor href={crumb.href}>
<BreadcrumbAnchor to={crumb.href}>
{crumb.label}
</BreadcrumbAnchor>
)}
Expand Down
36 changes: 28 additions & 8 deletions src/js/pages/ElectionFinder/ElectionFinderHome.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import {
SearchIconButton, SectionTitle, SectionTitleRow, ShowMoreButton,
StateSelectWrapper, StateSelectNative, StateSelectLabel, StateSelectCaret,
} from './electionFinderStyles';
import webAppConfig from '../../config';

const nextReleaseFeaturesEnabled = webAppConfig.ENABLE_NEXT_RELEASE_FEATURES === undefined ? false : webAppConfig.ENABLE_NEXT_RELEASE_FEATURES;

function formatDateUS (dateString) {
if (!dateString) return '';
Expand All @@ -34,15 +37,24 @@ const SORTED_STATES = Object.entries(stateCodeMap)

function ElectionFinderHome () {
renderLog('ElectionFinderHome');
const [copyLinkText, setCopyLinkText] = useState('Copy link');
const [electionList, setElectionList] = useState([]);
const [selectedStateCode, setSelectedStateCode] = useState('all');
const [filterTab, setFilterTab] = useState('upcoming');
const [visibleCount, setVisibleCount] = useState(50);
const [searchOpen, setSearchOpen] = useState(false);
const [searchText, setSearchText] = useState('');
const copyLinkTimeoutRef = useRef(null);
const searchInputRef = useRef(null);
const searchDebounceRef = useRef(null);

useEffect(() => () => {
// Clear timeout when component unmounts
if (copyLinkTimeoutRef.current) {
clearTimeout(copyLinkTimeoutRef.current);
}
}, []);

useEffect(() => {
window.scrollTo(0, 0);
const listener = ElectionStore.addListener(() => {
Expand Down Expand Up @@ -186,9 +198,11 @@ function ElectionFinderHome () {

<SectionTitleRow>
<SectionTitle>{sectionTitle}</SectionTitle>
<DarkTooltip title={sectionDownloadLabel}>
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
{nextReleaseFeaturesEnabled && (
<DarkTooltip title={sectionDownloadLabel}>
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
)}
</SectionTitleRow>

<ElectionList>
Expand All @@ -206,22 +220,28 @@ function ElectionFinderHome () {
{election.election_name || ''}
</ElectionLink>
<ElectionRowActions className="u-show-desktop-tablet" onClick={(e) => e.stopPropagation()}>
<DarkTooltip title="Copy link">
<DarkTooltip title={copyLinkText}>
<ActionChip onClick={() => {
setCopyLinkText('Copied!');
copyLinkTimeoutRef.current = setTimeout(() => {
setCopyLinkText('Copy link');
}, 3000);
const sc = (election.state_code_list && election.state_code_list.length > 0) ?
election.state_code_list[0].toLowerCase() :
'na';
navigator.clipboard.writeText(`${window.location.origin}/election-finder/${sc}/${googleCivicElectionId}`);
}}
>
<ContentCopy sx={{ fontSize: 14, mr: 0.5 }} />
Copy link
{copyLinkText}
</ActionChip>
</DarkTooltip>
<ActionDivider />
<DarkTooltip title="Download election data">
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
{nextReleaseFeaturesEnabled && (
<DarkTooltip title="Download election data">
<IconButton size="small"><FileDownloadOutlined fontSize="small" /></IconButton>
</DarkTooltip>
)}
<DarkTooltip title="Open in new tab">
<IconButton
size="small"
Expand Down
7 changes: 6 additions & 1 deletion src/js/pages/ElectionFinder/electionFinderStyles.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TextField, Tooltip, tooltipClasses } from '@mui/material';
import React from 'react'; // eslint-disable-line no-unused-vars
import { Link } from 'react-router-dom';
import styled from 'styled-components';

// eslint-disable-next-line react/jsx-props-no-spreading, react/react-in-jsx-scope
Expand Down Expand Up @@ -50,7 +51,7 @@ export const Breadcrumb = styled('div')`
margin-bottom: 8px;
`;

export const BreadcrumbAnchor = styled('a')`
export const BreadcrumbAnchor = styled(Link)`
color: #206bc4;
cursor: pointer;
text-decoration: none;
Expand Down Expand Up @@ -287,6 +288,10 @@ export const OfficeName = styled('span')`
color: #333;
`;

export const OfficePrimaryPartySpan = styled('span')`
font-weight: 400;
`;

export const OfficeSection = styled('div')`
`;

Expand Down
Loading