Skip to content

Commit

Permalink
Move capitalize first char fn to util module, use it in IssueListItem
Browse files Browse the repository at this point in the history
  • Loading branch information
GeordieP committed Oct 13, 2018
1 parent 6ea2225 commit 2b3e4fb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/components/Issue/Segments.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import { HTMLAttributes } from 'react';
import { capitalizeFirstChar as capitalize } from 'src/util/strings';

import './Issue.css';

Expand All @@ -9,8 +10,6 @@ interface Props extends HTMLAttributes<HTMLElement> {
children: any;
}

const capitalize = (str: string) => `${str[0].toUpperCase()}${str.slice(1)}`;

export default ({ issue, children, ...props }: Props) => {
const renderTitle = () => (
<h1 className='u-noMargin'>{issue.title}</h1>
Expand Down
5 changes: 3 additions & 2 deletions src/components/IssueList/IssueListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { HTMLAttributes } from 'react';
import * as classnames from 'classnames';
import { capitalizeFirstChar } from 'src/util/strings';

interface Props extends HTMLAttributes<HTMLElement> {
issue: Issue;
Expand All @@ -15,12 +16,12 @@ export default ({ issue, className, ...props }: Props) => (
<h4 data-testid='issueListItem_date'>
{new Date(issue.dateUpdated).toDateString()}
</h4>
<h4>{issue.type} | {issue.severity}</h4>
<h4>{capitalizeFirstChar(issue.type)} | {capitalizeFirstChar(issue.severity)}</h4>
</div>

<div className="u-flexH u-stretchH u-spaceBetween">
<h4 className="issueDetails">{issue.creator.username}</h4>
<h4>{issue.status}</h4>
<h4>{capitalizeFirstChar(issue.status)}</h4>
</div>
</div>
);
2 changes: 2 additions & 0 deletions src/util/strings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const capitalizeFirstChar = (str: string): string =>
`${str[0].toUpperCase()}${str.slice(1)}`;

0 comments on commit 2b3e4fb

Please sign in to comment.