diff --git a/src/components/Playground.tsx b/src/components/Playground.tsx index 5d44359..dd3b8c2 100644 --- a/src/components/Playground.tsx +++ b/src/components/Playground.tsx @@ -2,10 +2,11 @@ import './Playground.scss' import React, { FC } from 'react' import { ClassPicker } from './ClassPicker' import { RouteComponentProps } from 'react-router' -import { Icon } from './Icon'; -import { Tooltip } from './Tooltip'; -import { TalentSlot } from './TalentSlot'; -import { talentsById } from '../data/talents'; +import { Icon } from './Icon' +import { Tooltip } from './Tooltip' +import { Talent } from './Talent' +import { talentsById } from '../data/talents' +import { Map } from 'immutable' interface Props extends RouteComponentProps { // @@ -21,6 +22,10 @@ const iconNames = [ 'spell_shadow_requiem', ] +const talentIds = [ + 76, 181, 182, 821 +] + const DEEP_WOUNDS =

Rank 1/3

Your critical strikes cause the opponent to bleed, dealing 20% of your melee weapon's average damage over 12 sec.

@@ -44,7 +49,27 @@ const Section: FC = (props) => { export class Playground extends React.PureComponent { static whyDidYouRender = true + state = { + points: Map() + } + + handleTalentClick = (id) => { + const { points } = this.state + this.setState({ + points: points.set(id, points.get(id, 0) + 1) + }) + } + + handleTalentRightClick = (id) => { + const { points } = this.state + this.setState({ + points: points.set(id, Math.max(0, points.get(id, 0) - 1)) + }) + } + render() { + const { points } = this.state + return (
@@ -68,33 +93,49 @@ export class Playground extends React.PureComponent {
-
+
+

Static

- - - - -
+ +

Interactive

+
+ {talentIds.map(id => + + )} +
+
diff --git a/src/components/TalentSlot.scss b/src/components/Talent.scss similarity index 100% rename from src/components/TalentSlot.scss rename to src/components/Talent.scss diff --git a/src/components/TalentSlot.tsx b/src/components/Talent.tsx similarity index 90% rename from src/components/TalentSlot.tsx rename to src/components/Talent.tsx index 952d548..259b29e 100644 --- a/src/components/TalentSlot.tsx +++ b/src/components/Talent.tsx @@ -1,4 +1,4 @@ -import './TalentSlot.scss' +import './Talent.scss' import React, { FC } from 'react' import { Icon } from './Icon' import classNames from 'classnames' @@ -19,7 +19,7 @@ const defaultProps: Partial = { onRightClick: () => undefined } -export const TalentSlot: FC = (props) => { +export const Talent: FC = (props) => { const { talent, points, disabled } = props const showPoints = !disabled || points > 0 @@ -61,6 +61,6 @@ export const TalentSlot: FC = (props) => { ) } -TalentSlot.defaultProps = defaultProps +Talent.defaultProps = defaultProps -;(TalentSlot as any).whyDidYouRender = true \ No newline at end of file +// ;(Talent as any).whyDidYouRender = true \ No newline at end of file diff --git a/src/components/TalentTree.tsx b/src/components/TalentTree.tsx index 599c15e..5fd75f7 100644 --- a/src/components/TalentTree.tsx +++ b/src/components/TalentTree.tsx @@ -1,6 +1,6 @@ import React, { useCallback } from 'react' import { Map } from 'immutable' -import { TalentSlot } from './TalentSlot'; +import { Talent } from './Talent'; import { getPointsInSpec, canLearnTalent, calcMeetsRequirements } from '../lib/tree'; import { talentsBySpec, specNames, talentsById, talentToSpec } from '../data/talents' import { Arrow } from './Arrow' @@ -44,7 +44,7 @@ export const TalentTree: React.FC = ({ specId, knownTalents, availablePoi
{talents.map((talent) => -