aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-22 19:56:12 +0800
committerFabio Berger <me@fabioberger.com>2018-03-22 19:56:12 +0800
commit46b7fecafe283e814e2088373ec857747e4cf314 (patch)
treed9cbf5cf571231470b568ece2f051557e2b9e08b /packages
parente1341bc6d957d70a386c858cbdb64af5f284fd07 (diff)
downloaddexon-sol-tools-46b7fecafe283e814e2088373ec857747e4cf314.tar
dexon-sol-tools-46b7fecafe283e814e2088373ec857747e4cf314.tar.gz
dexon-sol-tools-46b7fecafe283e814e2088373ec857747e4cf314.tar.bz2
dexon-sol-tools-46b7fecafe283e814e2088373ec857747e4cf314.tar.lz
dexon-sol-tools-46b7fecafe283e814e2088373ec857747e4cf314.tar.xz
dexon-sol-tools-46b7fecafe283e814e2088373ec857747e4cf314.tar.zst
dexon-sol-tools-46b7fecafe283e814e2088373ec857747e4cf314.zip
Create helper function for converting dashes names for display
Diffstat (limited to 'packages')
-rw-r--r--packages/react-shared/src/components/markdown_section.tsx2
-rw-r--r--packages/react-shared/src/components/nested_sidebar_menu.tsx4
-rw-r--r--packages/react-shared/src/components/section_header.tsx2
-rw-r--r--packages/react-shared/src/utils/utils.ts3
4 files changed, 7 insertions, 4 deletions
diff --git a/packages/react-shared/src/components/markdown_section.tsx b/packages/react-shared/src/components/markdown_section.tsx
index e895afd2a..449e8a045 100644
--- a/packages/react-shared/src/components/markdown_section.tsx
+++ b/packages/react-shared/src/components/markdown_section.tsx
@@ -43,7 +43,7 @@ export class MarkdownSection extends React.Component<MarkdownSectionProps, Markd
const { sectionName, markdownContent, headerSize, githubLink } = this.props as PropsWithDefaults;
const id = utils.getIdFromName(sectionName);
- const finalSectionName = sectionName.replace(/-/g, ' ');
+ const finalSectionName = utils.convertDashesToSpaces(sectionName);
return (
<div
className="md-px1 sm-px2 overflow-hidden"
diff --git a/packages/react-shared/src/components/nested_sidebar_menu.tsx b/packages/react-shared/src/components/nested_sidebar_menu.tsx
index d81bd3c3d..f49d6fcf7 100644
--- a/packages/react-shared/src/components/nested_sidebar_menu.tsx
+++ b/packages/react-shared/src/components/nested_sidebar_menu.tsx
@@ -45,7 +45,7 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N
};
public render() {
const navigation = _.map(this.props.topLevelMenu, (menuItems: string[], sectionName: string) => {
- const finalSectionName = sectionName.replace(/-/g, ' ');
+ const finalSectionName = utils.convertDashesToSpaces(sectionName);
if (this.props.shouldDisplaySectionHeaders) {
const id = utils.getIdFromName(sectionName);
return (
@@ -85,7 +85,7 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N
: styles.menuItemWithoutHeaders;
const menuItemInnerDivStyles = this.props.shouldDisplaySectionHeaders ? styles.menuItemInnerDivWithHeaders : {};
const menuItems = _.map(menuItemNames, menuItemName => {
- const finalMenuItemName = menuItemName.replace(/-/g, ' ');
+ const finalMenuItemName = utils.convertDashesToSpaces(menuItemName);
const id = utils.getIdFromName(menuItemName);
return (
<div key={menuItemName}>
diff --git a/packages/react-shared/src/components/section_header.tsx b/packages/react-shared/src/components/section_header.tsx
index 2ef5f61ee..0224c2127 100644
--- a/packages/react-shared/src/components/section_header.tsx
+++ b/packages/react-shared/src/components/section_header.tsx
@@ -35,7 +35,7 @@ export class SectionHeader extends React.Component<SectionHeaderProps, SectionHe
public render() {
const { sectionName, headerSize } = this.props as PropsWithDefaults;
- const finalSectionName = this.props.sectionName.replace(/-/g, ' ');
+ const finalSectionName = utils.convertDashesToSpaces(this.props.sectionName);
const id = utils.getIdFromName(finalSectionName);
return (
<div
diff --git a/packages/react-shared/src/utils/utils.ts b/packages/react-shared/src/utils/utils.ts
index b3acb081e..1538dd087 100644
--- a/packages/react-shared/src/utils/utils.ts
+++ b/packages/react-shared/src/utils/utils.ts
@@ -30,6 +30,9 @@ export const utils = {
const id = name.replace(/ /g, '-');
return id;
},
+ convertDashesToSpaces(text: string) {
+ return text.replace(/-/g, ' ');
+ },
getEtherScanLinkIfExists(
addressOrTxHash: string,
networkId: number,