Skip to content

Commit

Permalink
Remove buggy ids from cards in card creator (#878)
Browse files Browse the repository at this point in the history
  • Loading branch information
smartin015 authored Jan 17, 2022
1 parent 4d34a7b commit b207969
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
3 changes: 2 additions & 1 deletion services/cards/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"scripts": {
"build": "webpack --config ./webpack.dist.config.js --display-error-details --verbose --progress",
"start": "webpack-dev-server --progress"
}
},
"dependencies": {}
}
8 changes: 1 addition & 7 deletions services/cards/src/helpers.test.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import * as React from 'react';
import {camelCase, horizontalCounter, romanize} from './helpers';
import {horizontalCounter, romanize} from './helpers';

describe('icon', () => {
test.skip('Returns JSX element', () => { /* TODO */ });
});

describe('camelCase', () => {
test('Skeleton Swordsman -> skeletonSwordsman', () => {
expect(camelCase('Skeleton Swordsman')).toEqual('skeletonSwordsman');
});
});

describe('romanize', () => {
test('0 -> 0', () => {
expect(romanize(0)).toEqual('0');
Expand Down
6 changes: 0 additions & 6 deletions services/cards/src/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ export function icon(name: string, theme?: string, key?: number): JSX.Element {
return <img key={(key === null) ? name : key} className={'inline_icon svg ' + name} src={themeSrc || globalSrc}/>;
}

export function camelCase(str: string): string {
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, (letter: string, index: number) => {
return index === 0 ? letter.toLowerCase() : letter.toUpperCase();
}).replace(/\s+/g, '').replace(/'/, '');
}

export function romanize(num: number): string { // http://blog.stevenlevithan.com/archives/javascript-roman-numeral-converter
if (+num === 0) { return '0'; }
if (!+num) { return ''; }
Expand Down
10 changes: 5 additions & 5 deletions services/cards/src/themes/BlackAndWhite/CardFront.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import {MAX_ADVENTURER_HEALTH} from '../../Constants';
import {camelCase, healthCounter, horizontalCounter, icon, lootCounter, translate, translateTier} from '../../helpers';
import {healthCounter, horizontalCounter, icon, lootCounter, translate, translateTier} from '../../helpers';
import {CardType} from '../../reducers/StateTypes';

export default class CardFront extends React.Component<CardType, {}> {
Expand All @@ -10,7 +10,7 @@ export default class CardFront extends React.Component<CardType, {}> {
switch (card.sheet) {
case 'Ability':
return (
<div className={`card front vertical ${card.sheet} ${card.classicon || card.class}`} id={camelCase(name)}>
<div className={`card front vertical ${card.sheet} ${card.classicon || card.class}`}>
<div className="contents">
<header>
<div className="typeicon">{card.typeicon}</div>
Expand Down Expand Up @@ -70,7 +70,7 @@ export default class CardFront extends React.Component<CardType, {}> {
);
case 'Adventurer':
return (
<div className={`card front horizontal ${card.sheet} bottomBar level${card.level}`} id={camelCase(card.name)}>
<div className={`card front horizontal ${card.sheet} bottomBar level${card.level}`}>
<div className="contents">
<header>
<div className="name">{card.name}</div>
Expand Down Expand Up @@ -158,7 +158,7 @@ export default class CardFront extends React.Component<CardType, {}> {
);
case 'Loot':
return (
<div className={`card front vertical ${card.sheet} tier${card.tier} ${card.tracker && 'tracker'} ${card.tracker > 14 && 'bottomBar'}`} id={camelCase(name)}>
<div className={`card front vertical ${card.sheet} tier${card.tier} ${card.tracker && 'tracker'} ${card.tracker > 14 && 'bottomBar'}`}>
<div className="contents">
<header>
<div className="name">{card.name}</div>
Expand Down Expand Up @@ -202,7 +202,7 @@ export default class CardFront extends React.Component<CardType, {}> {
);
case 'Skill':
return (
<div className={`card front horizontal ${card.sheet} bottomBar`} id={camelCase(card.name)}>
<div className={`card front horizontal ${card.sheet} bottomBar`}>
<div className="contents">
<header>
{card.typeicon && <div className="typeIcon">{icon((card.typeicon).toLowerCase() + '_small')}</div>}
Expand Down
10 changes: 5 additions & 5 deletions services/cards/src/themes/Color/CardFront.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import {MAX_ADVENTURER_HEALTH} from '../../Constants';
import {camelCase, healthCounter, horizontalCounter, icon, lootCounter, translate, translateTier} from '../../helpers';
import {healthCounter, horizontalCounter, icon, lootCounter, translate, translateTier} from '../../helpers';
import {CardType} from '../../reducers/StateTypes';

export default class CardFront extends React.Component<CardType, {}> {
Expand All @@ -20,7 +20,7 @@ export default class CardFront extends React.Component<CardType, {}> {
);
case 'Ability':
return (
<div className={`card front vertical ${card.sheet} ${card.class}`} id={camelCase(name)}>
<div className={`card front vertical ${card.sheet} ${card.class}`}>
<div className="contents">
<header>
<div className="typeicon">{card.typeicon}</div>
Expand Down Expand Up @@ -80,7 +80,7 @@ export default class CardFront extends React.Component<CardType, {}> {
);
case 'Adventurer':
return (
<div className={`card front horizontal ${card.sheet} bottomBar`} id={camelCase(card.name)}>
<div className={`card front horizontal ${card.sheet} bottomBar`}>
<div className="contents">
<header>
<div className="name">{card.name}</div>
Expand Down Expand Up @@ -157,7 +157,7 @@ export default class CardFront extends React.Component<CardType, {}> {
);
case 'Loot':
return (
<div className={`card front vertical ${card.sheet} tier${card.tier} ${card.tracker && 'tracker'} ${card.tracker > 14 && 'bottomBar'}`} id="{{camelCase name }}">
<div className={`card front vertical ${card.sheet} tier${card.tier} ${card.tracker && 'tracker'} ${card.tracker > 14 && 'bottomBar'}`}>
<div className="contents">
<header>
<div className="name">{card.name}</div>
Expand Down Expand Up @@ -201,7 +201,7 @@ export default class CardFront extends React.Component<CardType, {}> {
);
case 'Skill':
return (
<div className={`card front horizontal ${card.sheet} bottomBar`} id={camelCase(card.name)}>
<div className={`card front horizontal ${card.sheet} bottomBar`}>
<div className="contents">
<header>
{card.typeicon && <div className="typeIcon">{icon((card.typeicon).toLowerCase() + '_small')}</div>}
Expand Down

0 comments on commit b207969

Please sign in to comment.