Skip to content

Commit

Permalink
improve ios usabilty
Browse files Browse the repository at this point in the history
  • Loading branch information
andrico1234 committed Nov 11, 2019
1 parent fd7dd57 commit c550a2a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion example/mockData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const legsPushData: SkillType[] = [
title: 'Something Else',
children: [
{
id: 'shrimp-squat',
id: 'shrimp-squat-1',
icon: SquatIcon,
title: 'Shrimp Squat',
tooltip: {
Expand Down
10 changes: 8 additions & 2 deletions src/components/ui/Node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import styled, { BaseThemedCssFunction } from 'styled-components';
import { SELECTED_STATE, UNLOCKED_STATE, LOCKED_STATE } from '../constants';
import { Skill } from '../../models';
import Icon from './Icon';
import isIOSDevice from '../../helpers/isIOS';
import { SkillThemeType } from '../../';

const keyframes = require('styled-components').keyframes;
const css: BaseThemedCssFunction<any> = require('styled-components').css;
const css: BaseThemedCssFunction<SkillThemeType> = require('styled-components')
.css;

interface Props {
handleClick: VoidFunction;
Expand All @@ -19,6 +22,7 @@ interface StyledNodeProps {
selected: boolean;
unlocked: boolean;
locked: boolean;
isIOS: boolean;
}

const Node = React.forwardRef(
Expand All @@ -28,6 +32,7 @@ const Node = React.forwardRef(
handleClick();
}
}

const { handleClick, id, currentState, skill } = props;

return (
Expand All @@ -37,6 +42,7 @@ const Node = React.forwardRef(
ref={ref}
data-testid={id}
optional={skill.optional || false}
isIOS={isIOSDevice()}
selected={currentState === SELECTED_STATE}
unlocked={currentState === UNLOCKED_STATE}
locked={currentState === LOCKED_STATE}
Expand Down Expand Up @@ -155,8 +161,8 @@ const StyledNode = styled.div<StyledNodeProps>`
&:before {
opacity: 1;
height: 85%;
width: 95%;
transition: width 0.6s, height 0.6s;
width: ${(props: StyledNodeProps) => (props.isIOS ? 0 : '95%')};
}
}
`}
Expand Down
22 changes: 22 additions & 0 deletions src/helpers/isIOS.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function isIOSDevice() {
var iDevices = [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod',
];

if (!!navigator.platform) {
while (iDevices.length) {
if (navigator.platform === iDevices.pop()) {
return true;
}
}
}

return false;
}

export default isIOSDevice;

0 comments on commit c550a2a

Please sign in to comment.