Skip to content

Commit

Permalink
FeaturePanel: refactoring - move stuff to helpers/
Browse files Browse the repository at this point in the history
  • Loading branch information
zbycz committed Sep 25, 2021
1 parent ce05705 commit d021488
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/components/FeaturePanel/FeatureHeading.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import styled from 'styled-components';
import { EditIconButton } from './EditIconButton';
import { EditIconButton } from './helpers/EditIconButton';

const Wrapper = styled.div`
font-size: 36px;
Expand Down
2 changes: 1 addition & 1 deletion src/components/FeaturePanel/Property.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from 'styled-components';
import WebsiteRenderer from './renderers/WebsiteRenderer';
import OpeningHoursRenderer from './renderers/OpeningHoursRenderer';
import PhoneRenderer from './renderers/PhoneRenderer';
import { EditIconButton } from './EditIconButton';
import { EditIconButton } from './helpers/EditIconButton';

const Wrapper = styled.div`
position: relative;
Expand Down
5 changes: 3 additions & 2 deletions src/components/FeaturePanel/TagsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import styled from 'styled-components';
import truncate from 'lodash/truncate';

import { slashToOptionalBr, useToggleState } from '../helpers';
import { getUrlForTag, ToggleButton } from './helpers';
import { EditIconButton } from './EditIconButton';
import { getUrlForTag } from './helpers/getUrlForTag';
import { EditIconButton } from './helpers/EditIconButton';
import { buildAddress } from '../../services/helpers';
import { ToggleButton } from './helpers/ToggleButton';

const Wrapper = styled.div`
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled from 'styled-components';
import IconButton from '@material-ui/core/IconButton';
import Edit from '@material-ui/icons/Edit';
import React from 'react';
import { t } from '../../services/intl';
import { t } from '../../../services/intl';

const StyledIconButton = styled(IconButton)`
position: absolute !important; /* TODO mui styles takes precendence, why? */
Expand Down
17 changes: 17 additions & 0 deletions src/components/FeaturePanel/helpers/ToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import IconButton from '@material-ui/core/IconButton';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import ExpandLessIcon from '@material-ui/icons/ExpandLess';
import React from 'react';
import styled from 'styled-components';

const StyledToggleButton = styled(IconButton)`
position: absolute !important;
margin: -11px 0 0 0 !important;
`;

export const ToggleButton = ({ onClick, isShown }) => (
<StyledToggleButton onClick={onClick} aria-label="Toggle">
{!isShown && <ExpandMoreIcon fontSize="small" />}
{isShown && <ExpandLessIcon fontSize="small" />}
</StyledToggleButton>
);
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import ExpandLessIcon from '@material-ui/icons/ExpandLess';
import React from 'react';
import styled from 'styled-components';
import IconButton from '@material-ui/core/IconButton';

const urlRegExp = /^https?:\/\/.+/;

export const getUrlForTag = (k, v) => {
Expand Down Expand Up @@ -46,14 +40,3 @@ export const getUrlForTag = (k, v) => {

return null;
};

const StyledToggleButton = styled(IconButton)`
position: absolute !important;
margin: -11px 0 0 0 !important;
`;
export const ToggleButton = ({ onClick, isShown }) => (
<StyledToggleButton onClick={onClick} aria-label="Toggle">
{!isShown && <ExpandMoreIcon fontSize="small" />}
{isShown && <ExpandLessIcon fontSize="small" />}
</StyledToggleButton>
);
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { SimpleOpeningHours } from 'simple-opening-hours';
import styled from 'styled-components';
import AccessTime from '@material-ui/icons/AccessTime';
import { useToggleState } from '../../helpers';
import { ToggleButton } from '../helpers';
import { t } from '../../../services/intl';
import { ToggleButton } from '../helpers/ToggleButton';

interface SimpleOpeningHoursTable {
su: string[];
Expand Down

1 comment on commit d021488

@vercel
Copy link

@vercel vercel bot commented on d021488 Sep 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.