Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FeaturePanel: Polish feature header #918

Merged
merged 1 commit into from
Feb 3, 2025
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
15 changes: 5 additions & 10 deletions src/components/FeaturePanel/FeatureDescription.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from 'react';
import { Box, Grid, Stack, Typography } from '@mui/material';
import styled from '@emotion/styled';
import { Stack, Typography } from '@mui/material';
import { capitalize } from '../helpers';
import { t, Translation } from '../../services/intl';
import { useFeatureContext } from '../utils/FeatureContext';
import { TooltipButton } from '../utils/TooltipButton';
import { Feature } from '../../services/types';
import { OSM_WEBSITE } from '../../services/osm/consts';
import { NwrIcon } from './NwrIcon';
Expand Down Expand Up @@ -74,15 +72,12 @@ export const FeatureDescription = () => {
}

return (
<>
<span
style={{ paddingRight: 5, verticalAlign: 'middle', lineHeight: '14px' }}
>
<NwrIcon osmType={osmMeta.type} />
</span>
<Stack direction="row" gap={1.2} alignItems="center">
<NwrIcon osmType={osmMeta.type} />

{t('featurepanel.feature_description_osm', {
type: capitalize(type),
})}
</>
</Stack>
);
};
57 changes: 31 additions & 26 deletions src/components/FeaturePanel/FeatureHeading.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import React from 'react';
import styled from '@emotion/styled';
import EditIcon from '@mui/icons-material/Edit';
import { Box, IconButton, Stack, Tooltip, useMediaQuery } from '@mui/material';
import { IconButton, Tooltip, useMediaQuery } from '@mui/material';
import { useEditDialogContext } from './helpers/EditDialogContext';
import { PoiDescription } from './helpers/PoiDescription';
import { getLabel, getSecondaryLabel } from '../../helpers/featureLabel';
import { useFeatureContext } from '../utils/FeatureContext';
import { t } from '../../services/intl';
import { isMobileDevice } from '../helpers';
import { QuickActions } from './QuickActions/QuickActions';
import { NwrIcon } from './NwrIcon';
import { PROJECT_ID } from '../../services/project';

const isOpenClimbing = PROJECT_ID === 'openclimbing';

const StyledEditButton = styled(IconButton)`
position: relative;
top: 3px;
`;
import { css } from '@emotion/react';

const EditNameContainer = styled.div`
position: absolute;
Expand All @@ -27,6 +20,7 @@ const EditNameContainer = styled.div`
bottom: 0;
align-items: center;
display: flex;
margin-top: 3px;
background: ${({ theme }) => theme.palette.background.paper};
`;
const EditNameButton = () => {
Expand All @@ -39,9 +33,9 @@ const EditNameButton = () => {
return (
<EditNameContainer>
<Tooltip title={t('featurepanel.inline_edit_title')}>
<StyledEditButton onClick={() => openWithTag('name')} size="small">
<IconButton onClick={() => openWithTag('name')} size="small">
<EditIcon fontSize="small" />
</StyledEditButton>
</IconButton>
</Tooltip>
</EditNameContainer>
);
Expand All @@ -61,6 +55,7 @@ const HeadingsWrapper = styled.div`
`;

const Headings = () => {
const isOpenClimbing = PROJECT_ID === 'openclimbing';
const [isHovered, setIsHovered] = React.useState(false);

const onMouseEnter = () => {
Expand All @@ -75,9 +70,14 @@ const Headings = () => {
const secondaryLabel = getSecondaryLabel(feature);
return (
<HeadingsWrapper onMouseEnter={onMouseEnter} onMouseLeave={onMouseLeave}>
<Heading $deleted={feature?.deleted}>{label}</Heading>
<Heading $deleted={feature?.deleted} $isOpenClimbing={isOpenClimbing}>
{label}
</Heading>
{secondaryLabel && (
<SecondaryHeading $deleted={feature?.deleted}>
<SecondaryHeading
$deleted={feature?.deleted}
$isOpenClimbing={isOpenClimbing}
>
{secondaryLabel}
</SecondaryHeading>
)}
Expand All @@ -86,33 +86,38 @@ const Headings = () => {
);
};

const Heading = styled.h1<{ $deleted: boolean }>`
const Heading = styled.h1<{ $deleted: boolean; $isOpenClimbing: boolean }>`
font-size: 36px;
line-height: 1.2;
${isOpenClimbing &&
`
font-family: 'Piazzolla', sans-serif;
font-weight: 900;
`}
${({ $isOpenClimbing }) =>
$isOpenClimbing &&
css`
font-family: 'Piazzolla', sans-serif;
font-weight: 900;
font-size: 46px;
`}
margin: 0;
${({ $deleted }) => $deleted && 'text-decoration: line-through;'}
`;
const SecondaryHeading = styled.h2<{ $deleted: boolean }>`
const SecondaryHeading = styled.h2<{
$deleted: boolean;
$isOpenClimbing: boolean;
}>`
font-size: 24px;
line-height: 0.98;
${isOpenClimbing &&
`
font-family: 'Piazzolla', sans-serif;
font-weight: 900;
`}
${({ $isOpenClimbing }) =>
$isOpenClimbing &&
css`
font-family: 'Piazzolla', sans-serif;
font-weight: 900;
`}
margin: 0;
${({ $deleted }) => $deleted && 'text-decoration: line-through;'}
`;

export const FeatureHeading = React.forwardRef<HTMLDivElement>((_, ref) => {
// thw pwa needs space at the bottom
const isStandalone = useMediaQuery('(display-mode: standalone)');
const { feature } = useFeatureContext();

return (
<Container ref={ref} isStandalone={isStandalone}>
Expand Down