diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index 29c5fa4..599f465 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -6,22 +6,24 @@ interface Props { name?: string size?: 'small' | 'medium' | 'large' golden?: boolean + className?: string } const NOT_FOUND_ICON = 'inv_misc_questionmark' -export const Icon: FC = ({ name: defaultName, size = 'medium', golden = false, children }) => { +export const Icon: FC = (props) => { + const { name: defaultName, size = 'medium', golden = false, children } = props const [hasLoadedImage, setLoadedImage] = useState(false) const [fadeIn, setFadeIn] = useState(false) const [name, setName] = useState(defaultName) const bgSize = size !== 'small' ? 'large' : 'medium' - const url = `https://wow.zamimg.com/images/wow/icons/${bgSize}/${name}.jpg` + const url = name && `https://wow.zamimg.com/images/wow/icons/${bgSize}/${name}.jpg` const start = Date.now() useEffect(() => { - if (!name) return + if (!url) return const img = new Image() img.onload = () => { const loadTime = Date.now() - start @@ -32,9 +34,9 @@ export const Icon: FC = ({ name: defaultName, size = 'medium', golden = f } img.onerror = () => setName(NOT_FOUND_ICON) img.src = url - }, [name, url, start]) + }, [url, start]) - const className = classNames('icon', `icon--${size}`, { + const className = classNames('icon', `icon--${size}`, props.className, { 'icon--golden': golden, 'icon--loaded': hasLoadedImage, 'icon--fade-in': fadeIn, @@ -42,7 +44,7 @@ export const Icon: FC = ({ name: defaultName, size = 'medium', golden = f return (
- {name && + {url &&
}
diff --git a/src/components/Playground.scss b/src/components/Playground.scss index 84256f0..7681e6f 100644 --- a/src/components/Playground.scss +++ b/src/components/Playground.scss @@ -6,4 +6,10 @@ &:last-child { margin-bottom: 0; } +} + +.playground-section__spelltooltip { + .tooltip { + margin-bottom: 1rem; + } } \ No newline at end of file diff --git a/src/components/Playground.tsx b/src/components/Playground.tsx index dd3b8c2..9eac8a4 100644 --- a/src/components/Playground.tsx +++ b/src/components/Playground.tsx @@ -7,6 +7,8 @@ import { Tooltip } from './Tooltip' import { Talent } from './Talent' import { talentsById } from '../data/talents' import { Map } from 'immutable' +import { SpellTooltip } from './SpellTooltip'; +import classNames from 'classnames' interface Props extends RouteComponentProps { // @@ -38,7 +40,7 @@ const DEEP_WOUNDS = const Section: FC = (props) => { return
-
+

{props.title}

{props.children} @@ -152,6 +154,11 @@ export class Playground extends React.PureComponent { And even link to exciting places! +

With title and icon

+ +

And some description text here

+
+

Fixed width

{DEEP_WOUNDS} @@ -165,6 +172,12 @@ export class Playground extends React.PureComponent { fixed: false })} + +
+ + + +
) } diff --git a/src/components/SpellTooltip.tsx b/src/components/SpellTooltip.tsx new file mode 100644 index 0000000..9d79fc5 --- /dev/null +++ b/src/components/SpellTooltip.tsx @@ -0,0 +1,21 @@ +import React, { FC } from 'react' +import { Tooltip } from './Tooltip' +import spells from '../data/spells.json' + +interface Props { + id: number +} + +export const SpellTooltip: FC = ({ id }) => { + const spell: SpellData = spells[id.toString()] + if (!spell) { + return Spell not found :( + } + + return + {spell.rank && +

Rank {spell.rank}

+ } +

{spell.description}

+
+} \ No newline at end of file diff --git a/src/components/Talent.scss b/src/components/Talent.scss index 954d548..d94aa15 100644 --- a/src/components/Talent.scss +++ b/src/components/Talent.scss @@ -6,7 +6,7 @@ height: 40px; border-radius: 5px; transition: filter .1s linear; - box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, .75); + box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, .75); filter: none; cursor: pointer; diff --git a/src/components/TalentTree.tsx b/src/components/TalentTree.tsx index c87a04a..757aedb 100644 --- a/src/components/TalentTree.tsx +++ b/src/components/TalentTree.tsx @@ -2,8 +2,8 @@ import './TalentTree.scss' import React, { useCallback } from 'react' import { Map } from 'immutable' import { Talent } from './Talent'; -import { getPointsInSpec, canLearnTalent, calcMeetsRequirements, SORT_TALENTS_DESC } from '../lib/tree'; -import { talentsBySpec, specNames, talentsById, talentToSpec } from '../data/talents' +import { getPointsInSpec, canLearnTalent, SORT_TALENTS_DESC } from '../lib/tree'; +import { talentsBySpec, specNames, talentsById } from '../data/talents' import { Arrow } from './Arrow' interface Props { @@ -36,9 +36,8 @@ export const TalentTree: React.FC = ({ specId, knownTalents, availablePoi const points = knownTalents.get(talent.id, 0) const canLearn = canLearnTalent(knownTalents, talent) - return - + = ({ specId, knownTalents, availablePoi /> {!!talent.requires.length && - 0 || canLearn} diff --git a/src/components/Tooltip.scss b/src/components/Tooltip.scss index 68f18da..4f75b5a 100644 --- a/src/components/Tooltip.scss +++ b/src/components/Tooltip.scss @@ -22,7 +22,7 @@ &__body { min-height: 2px; - padding: 8px 4px 2px 10px; + padding: 8px 3px 2px 9px; background: url('../images/tooltip-background.png'); background-position: top left; } @@ -50,16 +50,17 @@ .tooltip { @include tooltip-base; + display: flex; &--inline { display: inline-block; } &--fixed { - width: 320px; - + .tooltip__inner { width: 100%; + width: 320px; } .tooltip__body { @@ -67,10 +68,14 @@ } } + &__icon { + margin-right: .25em; + transform: translateY(2px); + } + &__title { font-size: 14px; line-height: 1.3; - // margin-bottom: 1px; } &__body { diff --git a/src/components/Tooltip.tsx b/src/components/Tooltip.tsx index 7a9d882..fa4d5fd 100644 --- a/src/components/Tooltip.tsx +++ b/src/components/Tooltip.tsx @@ -1,6 +1,7 @@ import './Tooltip.scss' import React, { FC } from 'react' import classNames from 'classnames' +import { Icon } from './Icon' interface Props { title?: string @@ -10,6 +11,8 @@ interface Props { fixed?: boolean /** Display tooltip inline */ inline?: boolean + /** Icon to show next to tooltip */ + icon?: string } export const Tooltip: FC = (props) => { @@ -24,8 +27,11 @@ export const Tooltip: FC = (props) => { width: props.width } - return
-
+ return
+ {props.icon && + + } +
{title &&
{title}
}