Skip to content

Commit

Permalink
updated styles and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
William Nadeau committed Apr 27, 2018
1 parent 1af46ec commit c2eb91a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/sheet/SheetApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class MockSheetApi implements SheetApi {
name: 'constitution modifier', modifiers: [
{ source: 'constitution', formula: '([constitution] - 10) / 2' }]
},
{ name: 'example', modifiers: [{ formula: 'min(-1, 1)' }] },
{ name: 'dexterity', modifiers: [{ formula: '14' }] },
{ name: 'dexterity modifier', modifiers: [{ source: 'dexterity', formula: '([dexterity] - 10) / 2' }] },
{
Expand Down
11 changes: 8 additions & 3 deletions src/sheetManage/ConditionalTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ const toRow = (key: string, conditional: Conditional, sheet: Sheet) => {
return (
<tr key={key}>
<td>{conditional.condition}</td>
<td colSpan={conditional.source ? 1 : 2}>
{conditional.formula === calculatedValue ? conditional.formula : `${conditional.formula} (${calculatedValue})`}
<td className="text-center">
{conditional.formula === calculatedValue
? conditional.formula
: `"${conditional.formula}" => ${calculatedValue}`}
</td>
<td>{conditional.source}</td>
<td>
<button className="fill-cell m-0 btn btn-light">...</button>
</td>
{conditional.source && <td>{conditional.source}</td>}
</tr>
);
};
Expand Down
30 changes: 21 additions & 9 deletions src/sheetManage/ModifierTable.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
import * as React from 'react';
import { Modifier } from '../sheet/SheetModel';
import Sheet, { Modifier, calculateFormula } from '../sheet/SheetModel';
import combineClasses from '../controls/combineClasses';

const ModifierTable: React.StatelessComponent<{ className?: string, modifiers: Modifier[] }> =
({ className, modifiers }) => {
const toRow = (key: string, sheet: Sheet, modifier: Modifier) => {
var calculatedValue = calculateFormula(sheet, modifier.formula).toString();

return (
<tr key={key}>
<td>{modifier.source}</td>
<td className="text-center">
{modifier.formula === calculatedValue
? modifier.formula
: `"${modifier.formula}" => ${calculatedValue}`}</td>
<td>
<button className="fill-cell m-0 btn btn-light">...</button>
</td>
</tr>
);
};

const ModifierTable: React.StatelessComponent<{ className?: string, sheet: Sheet, modifiers: Modifier[] }> =
({ className, sheet, modifiers }) => {

const classes = combineClasses(className, 'table-responsive');

return (
<div className={classes}>
<table className="table table-no-hover m-0">
<tbody>
{modifiers.map((modifier, index) => (
<tr key={index.toString()}>
<td colSpan={modifier.source ? 1 : 2}>{modifier.formula}</td>
{modifier.source && <td>{modifier.source}</td>}
</tr>
))}
{modifiers.map((modifier, index) => toRow(index.toString(), sheet, modifier))}
</tbody>
</table>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/sheetManage/StatisticsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class StatisticsPanel extends React.Component<StatisticsPanelProps, { exp
{hasConditionals && <h6 className="m-2">conditionals</h6>}
{hasConditionals && <ConditionalTable sheet={sheet} conditionals={statistic.conditionals!} />}
{hasModifiers && <h6 className="m-2">modifiers</h6>}
{hasModifiers && <ModifierTable modifiers={statistic.modifiers!} />}
{hasModifiers && <ModifierTable sheet={sheet} modifiers={statistic.modifiers!} />}

<button className="btn btn-outline-danger float-right btn-small d-inline">Delete</button>
<button className="btn btn-outline-primary float-right btn-small d-inline">Add Modifier</button>
Expand Down
6 changes: 6 additions & 0 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@
border-top-width: 5px;
border-top-style: solid;
border-top-color: lightskyblue;
background-color:lightgray;
font-weight: bold;
}

.fill-cell {
height:100%;
width:100%;
}

0 comments on commit c2eb91a

Please sign in to comment.