From f6d888fd91d5c51bd2a5ae6a25747ad87d609958 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 17 Nov 2018 13:46:18 +0200 Subject: [PATCH] Refactor classname mapping --- src/components/Button/Button.tsx | 14 ++++++++++++-- src/components/Button/index.ts | 3 ++- src/components/PageSection/PageSection.tsx | 14 +++++--------- src/pages/FrontPage/FrontPage.tsx | 6 +++--- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/components/Button/Button.tsx b/src/components/Button/Button.tsx index adb9f3d..66ffaeb 100644 --- a/src/components/Button/Button.tsx +++ b/src/components/Button/Button.tsx @@ -1,15 +1,25 @@ import * as React from "react"; import "./Button.scss"; +export enum ButtonType { + Hero, + Filled, +} + +const buttonClassNames = new Map([ + [ButtonType.Hero, "hero"], + [ButtonType.Filled, "filled"], +]); + export interface ButtonProps { onClick: () => void; - type: string; + type: ButtonType; } export default class Button extends React.Component { render() { const { type } = this.props; - const className = `button ${type}`; + const className = `button ${buttonClassNames.get(type)}`; return ( - + + Kikkeli