Skip to content

Commit 234abda

Browse files
refactor: constant/index file refactored (#1561)
Co-authored-by: Priyankar Pal <[email protected]>
1 parent 5bea781 commit 234abda

File tree

7 files changed

+22
-18
lines changed

7 files changed

+22
-18
lines changed

src/common/footer/ExtendedFooter.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useSearchContext } from 'common/search/search-context';
2-
import { CREATE_PLAY_DOC_LINK } from 'constants';
2+
import { PLAY_DOC_LINK } from 'constants';
33
import LogoLight from 'images/img-logo-light.svg';
44
import { BsGithub } from 'react-icons/bs';
55
import { FaDiscord, FaLinkedin, FaMeetup } from 'react-icons/fa';
@@ -105,7 +105,7 @@ const ExtendedFooter = () => {
105105
<div className="my-4 py-4 mx-auto">
106106
<a
107107
className="btn-primary mr-2 mb-2"
108-
href={CREATE_PLAY_DOC_LINK}
108+
href={PLAY_DOC_LINK}
109109
rel="noopener noreferrer"
110110
target="_blank"
111111
>

src/common/header/HeaderNav.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import SocialShare from 'common/components/SocialShare';
1010
import { GoX } from 'react-icons/go';
1111
import { Modal, Box, Typography, Menu } from '@mui/material';
1212
import { useSearchContext } from 'common/search/search-context';
13-
import { CREATE_PLAY_DOC_LINK, UMAMI_EVENTS } from 'constants';
13+
import { PLAY_DOC_LINK, UMAMI_EVENTS } from 'constants';
1414

1515
const HeaderNav = ({ showBrowse }) => {
1616
const { showShareModal, setShowShareModal } = useSearchContext();
@@ -173,7 +173,7 @@ const HeaderNav = ({ showBrowse }) => {
173173
className="app-header-btn app-header-btn--primary"
174174
data-testid="create-btn"
175175
data-umami-event={UMAMI_EVENTS.CREATE_PLAY_BUTTON}
176-
href={CREATE_PLAY_DOC_LINK}
176+
href={PLAY_DOC_LINK}
177177
rel="noopener noreferrer"
178178
target="_blank"
179179
>

src/common/playcreated/PlayCreated.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { toKebabCase } from 'common/services/string';
44
import { useEffect, useState } from 'react';
55
import { useParams } from 'react-router-dom';
66
import './play-created.scss';
7-
import { CREATE_PLAY_DOC_LINK } from 'constants';
7+
import { PLAY_DOC_LINK } from 'constants';
88

99
const PlayCreated = () => {
1010
const { playid } = useParams();
@@ -95,7 +95,7 @@ const PlayCreated = () => {
9595
Refer{' '}
9696
<a
9797
className="play-create-anchor"
98-
href={CREATE_PLAY_DOC_LINK}
98+
href={PLAY_DOC_LINK}
9999
rel="noopener noreferrer"
100100
target="_blank"
101101
>

src/common/playideas/PlayIdeas.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { IoAddSharp } from 'react-icons/io5';
44
import { RiChatNewLine } from 'react-icons/ri';
55
import LevelBadge from 'common/components/LevelBadge';
66
import './playIdeas.css';
7-
import { CREATE_PLAY_DOC_LINK } from 'constants';
7+
import { PLAY_DOC_LINK } from 'constants';
88

99
const PlayIdeas = () => {
1010
const [ideas, setIdeas] = useState([]);
@@ -145,7 +145,7 @@ const PlayIdeas = () => {
145145
) : (
146146
<a
147147
className="btn-primary action-btn"
148-
href={CREATE_PLAY_DOC_LINK}
148+
href={PLAY_DOC_LINK}
149149
rel="noopener noreferrer"
150150
target="_blank"
151151
>

src/common/playlists/PlayList.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React, { Fragment, useEffect, useState } from 'react';
44
import 'react-loader-spinner/dist/loader/css/react-spinner-loader.css';
55
import Loader from 'common/spinner/spinner';
66
import * as all_plays from 'plays';
7-
import { SORT_BY } from 'constants';
7+
import { SORT_OPTIONS } from 'constants';
88
import './playlist.css';
99
import { toSanitized } from 'common/services/string';
1010
import DynamicBanner from './DynamicBanner';
@@ -110,7 +110,7 @@ const PlayList = () => {
110110
<div className="sort-by-plays-wrapper">
111111
Sort By :
112112
<select id="sort-by-plays" name="sort-by-plays" value={sortBy} onChange={onChange}>
113-
{SORT_BY.map((name, i) => (
113+
{SORT_OPTIONS.map((name, i) => (
114114
<option key={i} value={name}>
115115
{name}
116116
</option>

src/constants/index.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
export const CREATE_PLAY_DOC_LINK = 'https://docs.reactplay.io/How-To-Guides/how-to-create-play';
2-
export const UMAMI_EVENTS = {
3-
GITHUB_BUTTON: 'github-button',
4-
CREATE_PLAY_BUTTON: 'create-play-button'
5-
};
1+
// URLs
2+
export const PLAY_DOC_LINK = 'https://docs.reactplay.io/How-To-Guides/how-to-create-play';
63

7-
export const SORT_BY = ['Newest', 'Oldest', 'Most Liked', 'Random'];
4+
// Event Types for Umami Analytics
5+
export const UMAMI_EVENTS = Object.freeze({
6+
GITHUB_BUTTON_CLICK: 'github-button',
7+
CREATE_PLAY_BUTTON_CLICK: 'create-play-button'
8+
});
9+
10+
// Sorting Options for Plays
11+
export const SORT_OPTIONS = Object.freeze(['Newest', 'Oldest', 'Most Liked', 'Random']);

src/plays/navbar/Backgrounds.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import ideas from './backgroundImages/bg_ideas.png';
33
import join from './backgroundImages/bg_join.png';
44
import create from './backgroundImages/bg_create.png';
55
import search from './backgroundImages/bg_search.png';
6-
import { CREATE_PLAY_DOC_LINK } from 'constants';
6+
import { PLAY_DOC_LINK } from 'constants';
77
const Backgrounds = [
88
{
99
id: 1,
@@ -40,7 +40,7 @@ const Backgrounds = [
4040
discription: 'Ready to create a new play? It is super easy, click down below to get started.',
4141
statement: 'Create Now',
4242
image: create,
43-
url: CREATE_PLAY_DOC_LINK
43+
url: PLAY_DOC_LINK
4444
},
4545
{
4646
id: 5,

0 commit comments

Comments
 (0)