diff --git a/src/App.scss b/src/App.scss index c009a84..aed20bd 100644 --- a/src/App.scss +++ b/src/App.scss @@ -64,6 +64,24 @@ a { margin-right: 1em; background-color: #111; + .talent { + position: absolute; + + // Rows + @for $i from 0 through 6 { + &[data-row="#{$i}"] { + top: $row-offset + (($i) * $row-distance); + } + } + + // Columns + @for $i from 0 through 3 { + &[data-col="#{$i}"] { + left: $col-offset + ($col-distance * $i); + } + } + } + &:last-child { margin-right: 0; } diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index 7b33739..29c5fa4 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -32,7 +32,7 @@ export const Icon: FC = ({ name: defaultName, size = 'medium', golden = f } img.onerror = () => setName(NOT_FOUND_ICON) img.src = url - }, [name, url]) + }, [name, url, start]) const className = classNames('icon', `icon--${size}`, { 'icon--golden': golden, diff --git a/src/components/Playground.tsx b/src/components/Playground.tsx index 479fe8a..5d44359 100644 --- a/src/components/Playground.tsx +++ b/src/components/Playground.tsx @@ -4,6 +4,8 @@ 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'; interface Props extends RouteComponentProps { // @@ -66,6 +68,35 @@ export class Playground extends React.PureComponent { +
+
+ + + + + + + + + +
+
+

No params

diff --git a/src/components/TalentSlot.scss b/src/components/TalentSlot.scss index 5c1edea..a411e05 100644 --- a/src/components/TalentSlot.scss +++ b/src/components/TalentSlot.scss @@ -1,7 +1,7 @@ @import "../sass/config"; .talent { - position: absolute; + position: relative; width: 40px; height: 40px; border-radius: 5px; @@ -11,7 +11,6 @@ &--available { .talent__status::after { - // background-color: rgba($color-green, .8); box-shadow: inset 0px 0px 6px 3px rgba($color-green, .8); } @@ -38,20 +37,6 @@ } } - // Rows - @for $i from 0 through 6 { - &[data-row="#{$i}"] { - top: $row-offset + (($i) * $row-distance); - } - } - - // Columns - @for $i from 0 through 3 { - &[data-col="#{$i}"] { - left: $col-offset + ($col-distance * $i); - } - } - &__status { position: absolute; width: 48px; diff --git a/src/components/TalentSlot.tsx b/src/components/TalentSlot.tsx index 802f7aa..a774608 100644 --- a/src/components/TalentSlot.tsx +++ b/src/components/TalentSlot.tsx @@ -2,45 +2,31 @@ import './TalentSlot.scss' import React, { FC } from 'react' import { Icon } from './Icon' import classNames from 'classnames' -import { Map } from 'immutable'; -import { getPointsInSpec, calcMeetsRequirements } from '../lib/tree'; interface Props { talent: TalentData - specId: number - availablePoints: number - /** All spent talents */ - knownTalents: Map - /** Disabled override */ + specId?: number + points?: number disabled?: boolean onClick?: (talentId: number) => void onRightClick?: (talentId: number) => void } const defaultProps: Partial = { + points: 0, + disabled: false, onClick: () => undefined, onRightClick: () => undefined } -const isAvailable = (talent: TalentData, specId: number, knownTalents: Map): boolean => { - // Dependent on other talents? - if (!calcMeetsRequirements(talent, knownTalents)) { - return false - } - const pointsInSpec = getPointsInSpec(specId, knownTalents) - return talent.row * 5 <= pointsInSpec -} - export const TalentSlot: FC = (props) => { - const { talent, specId, knownTalents, availablePoints } = props - const points = knownTalents.get(talent.id, 0) - const showPoints = points > 0 || availablePoints > 0 - const disabled = props.disabled || !showPoints || !isAvailable(talent, specId, knownTalents) + const { talent, points, disabled } = props + const showPoints = !disabled || points > 0 const containerClassNames = classNames('talent', { - 'talent--disabled': !!disabled, + 'talent--disabled': disabled && points === 0, 'talent--available': !disabled && points < talent.ranks.length, - 'talent--maxed': points >= talent.ranks.length || (points > 0 && availablePoints === 0) + 'talent--maxed': points >= talent.ranks.length || (points > 0 && disabled) }) const pointsClassNames = classNames('point-label', { @@ -65,7 +51,7 @@ export const TalentSlot: FC = (props) => {
- {showPoints && !disabled && + {showPoints &&
{points} /{talent.ranks.length} diff --git a/src/components/TalentTree.tsx b/src/components/TalentTree.tsx index 88bbf25..599c15e 100644 --- a/src/components/TalentTree.tsx +++ b/src/components/TalentTree.tsx @@ -1,8 +1,8 @@ import React, { useCallback } from 'react' import { Map } from 'immutable' import { TalentSlot } from './TalentSlot'; -import { getPointsInSpec, canLearnTalent } from '../lib/tree'; -import { talentsBySpec, specNames, talentsById } from '../data/talents' +import { getPointsInSpec, canLearnTalent, calcMeetsRequirements } from '../lib/tree'; +import { talentsBySpec, specNames, talentsById, talentToSpec } from '../data/talents' import { Arrow } from './Arrow' interface Props { @@ -46,12 +46,11 @@ export const TalentTree: React.FC = ({ specId, knownTalents, availablePoi {talents.map((talent) => )} @@ -61,4 +60,15 @@ export const TalentTree: React.FC = ({ specId, knownTalents, availablePoi ) } +// move this somewhere else/revise this +export const isAvailable = (talent: TalentData, knownTalents: Map): boolean => { + // Dependent on other talents? + if (!calcMeetsRequirements(talent, knownTalents)) { + return false + } + const specId = talentToSpec[talent.id] + const pointsInSpec = getPointsInSpec(specId, knownTalents) + return talent.row * 5 <= pointsInSpec +} + ;(TalentTree as any).whyDidYouRender = true \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 0980b23..81a8a7f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "strict": true, + "strict": false, "forceConsistentCasingInFileNames": true, "module": "esnext", "moduleResolution": "node", @@ -21,5 +21,8 @@ }, "include": [ "src" + ], + "exclude": [ + "src/lib/foo.ts" ] }