From 73507a0b6c741c35a205a87e6fe9704bdc7351e9 Mon Sep 17 00:00:00 2001 From: andrico Date: Sun, 15 Dec 2019 16:29:09 +0000 Subject: [PATCH] add default/alternative style to nodes --- example/index.tsx | 25 ++++++++++++++++--------- example/mockData.tsx | 1 + src/components/ui/Node.tsx | 30 ++++++++++++++++++++++++++++-- src/models/index.ts | 1 + src/theme/index.ts | 9 +++++++++ 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/example/index.tsx b/example/index.tsx index ed03173..504769e 100644 --- a/example/index.tsx +++ b/example/index.tsx @@ -1,20 +1,20 @@ import 'react-app-polyfill/ie11'; import * as React from 'react'; import * as ReactDOM from 'react-dom'; -// import { -// SkillTree, -// SkillTreeGroup, -// SkillProvider, -// SkillGroupDataType, -// SavedDataType, -// } from '../src'; import { SkillTree, SkillTreeGroup, SkillProvider, SkillGroupDataType, SavedDataType, -} from '../dist/index'; +} from '../src'; +// import { +// SkillTree, +// SkillTreeGroup, +// SkillProvider, +// SkillGroupDataType, +// SavedDataType, +// } from '../dist/index'; import './index.css'; import { legsPushData, legsPullData, hpSavedData } from './mockData'; import { ContextStorage } from '../src/models'; @@ -31,7 +31,14 @@ function handleSave( const App = () => { return ( - + {({ skillCount, selectedSkillCount, diff --git a/example/mockData.tsx b/example/mockData.tsx index 37fddd3..c3aecee 100644 --- a/example/mockData.tsx +++ b/example/mockData.tsx @@ -67,6 +67,7 @@ export const legsPushData: SkillType[] = [ { id: 'ass-pistol-squat', title: 'Pistol Squat (Assisted)', + color: 'alternative', tooltip: { content: , }, diff --git a/src/components/ui/Node.tsx b/src/components/ui/Node.tsx index 9d0ee91..4ccdebc 100644 --- a/src/components/ui/Node.tsx +++ b/src/components/ui/Node.tsx @@ -23,6 +23,11 @@ interface StyledNodeProps { unlocked: boolean; locked: boolean; isIOS: boolean; + color: 'default' | 'alternative'; +} + +interface TextProp { + selected: boolean; } const Node = React.forwardRef(function Node( @@ -30,6 +35,7 @@ const Node = React.forwardRef(function Node( ref: React.Ref ) { const { handleClick, id, currentState, skill } = props; + const { color = 'default' } = skill; const [isIOS, setIsIOS] = React.useState(false); const memoizedHandleKeyDown = React.useCallback( @@ -57,6 +63,7 @@ const Node = React.forwardRef(function Node( selected={currentState === SELECTED_STATE} unlocked={currentState === UNLOCKED_STATE} locked={currentState === LOCKED_STATE} + color={color} > {'icon' in skill ? ( @@ -64,7 +71,13 @@ const Node = React.forwardRef(function Node( ) : ( - {skill.title} + {color === 'default' ? ( + {skill.title} + ) : ( + + {skill.title} + + )} )} @@ -126,7 +139,10 @@ const StyledNode = styled.div` props.selected && css` animation: ${shadowburst} 1s 1; - background: ${({ theme }) => theme.nodeActiveBackgroundColor}; + background: ${({ theme }) => + props.color === 'default' + ? theme.nodeAlternativeActiveBackgroundColor + : theme.nodeActiveBackgroundColor}; `} ${props => @@ -222,3 +238,13 @@ const Text = styled.p` font-size: ${({ theme }) => theme.nodeDesktopFontSize}; } `; + +const AlternativeText = styled(Text)` + color: ${({ theme }) => theme.nodeAlternativeFontColor}; + + ${props => + props.selected && + css` + color: ${({ theme }) => theme.nodeAltenativeActiveFontColor}; + `}; +`; diff --git a/src/models/index.ts b/src/models/index.ts index aaa6841..ee396ba 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -46,6 +46,7 @@ export type ActionType = interface BaseSkill { id: string; optional?: boolean; + color?: 'default' | 'alternative'; title: string; tooltip: Tooltip; children: Skill[]; diff --git a/src/theme/index.ts b/src/theme/index.ts index 59f24be..1fd43f8 100644 --- a/src/theme/index.ts +++ b/src/theme/index.ts @@ -15,7 +15,16 @@ const defaultTheme = { tooltipFontColor: '#16181c', nodeBackgroundColor: '#282c34', nodeBorderColor: 'white', + nodeAlternativeFontColor: 'white', + nodeAltenativeActiveFontColor: 'white', nodeOverlayColor: 'white', + nodeAlternativeActiveBackgroundColor: ` + linear-gradient( + to right, + #b9e562 0%, + #41e2bd 50%, + #c284d8 100% + )`, nodeActiveBackgroundColor: `linear-gradient( to right, #b9e562 0%,