This repository has been archived by the owner on May 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
style(Navigation): implement switch cases for code reduction - I91
Signed-off-by: irmerk <[email protected]>
- Loading branch information
1 parent
3ab0de7
commit 402e946
Showing
2 changed files
with
32 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
export const isClause = input => input === 'clause'; | ||
export const isHeadingOne = input => input === 'heading_one'; | ||
export const isHeadingTwo = input => input === 'heading_two'; | ||
export const isHeadingThree = input => input === 'heading_three'; | ||
|
||
const truncateHeading = (heading, length) => ((heading.length > length) | ||
? `${heading.substring(0, length)}...` | ||
: heading); | ||
|
||
|
||
export const truncateHeader = ({ type, text }) => { | ||
if (isClause(type)) return truncateHeading(text, 20); | ||
if (isHeadingOne(type)) return truncateHeading(text, 22); | ||
if (isHeadingTwo(type)) return truncateHeading(text, 18); | ||
if (isHeadingThree(type)) return truncateHeading(text, 14); | ||
return 'Error!'; | ||
switch (type) { | ||
case 'clause': | ||
return truncateHeading(text, 20); | ||
case 'heading_one': | ||
return truncateHeading(text, 22); | ||
case 'heading_two': | ||
return truncateHeading(text, 18); | ||
case 'heading_three': | ||
return truncateHeading(text, 14); | ||
default: | ||
return 'Error!'; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters