Skip to content

Commit

Permalink
Refactor / Codepen Added
Browse files Browse the repository at this point in the history
Refactor to more accurately name components.

Codepen icon and item added.
  • Loading branch information
danielcranney committed Mar 10, 2022
1 parent 92065c9 commit 48f2218
Show file tree
Hide file tree
Showing 13 changed files with 143 additions and 125 deletions.
6 changes: 3 additions & 3 deletions components/IntroductionArticle.js → components/IntroItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ACTIONS } from "../pages/_app";
import FormLabel from "./forms/FormLabel";
import FormInput from "./forms/FormInput";

const IntroductionArticle = forwardRef((props, ref) => {
const IntroItem = forwardRef((props, ref) => {
const { formLabelText, formLabelIcon, section, type, inputPlaceholder } =
props;
return (
Expand All @@ -20,6 +20,6 @@ const IntroductionArticle = forwardRef((props, ref) => {
);
});

IntroductionArticle.displayName = "IntroductionArticle";
IntroItem.displayName = "IntroItem";

export default IntroductionArticle;
export default IntroItem;
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useContext, forwardRef } from "react";
import { ACTIONS } from "../pages/_app";
import SocialInput from "./SocialInput";
import SocialInput from "./forms/MinimalFormInput";

const IntroductionArticleWithLink = forwardRef((props, ref) => {
const IntroLinkItem = forwardRef((props, ref) => {
const { section, type, inputPlaceholder, linkPrefix } = props;
return (
<article className="flex flex-col flex-1 w-full">
Expand All @@ -22,6 +22,6 @@ const IntroductionArticleWithLink = forwardRef((props, ref) => {
);
});

IntroductionArticleWithLink.displayName = "IntroductionArticleWithLink";
IntroLinkItem.displayName = "IntroLinkItem";

export default IntroductionArticleWithLink;
export default IntroLinkItem;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ACTIONS } from "../pages/_app";
import FormLabel from "./forms/FormLabel";
import FormTextarea from "./forms/FormTextarea";

const IntroductionTextarea = forwardRef((props, ref) => {
const IntroTextarea = forwardRef((props, ref) => {
const { formLabelText, formLabelIcon, section, type, inputPlaceholder } =
props;
return (
Expand All @@ -20,6 +20,6 @@ const IntroductionTextarea = forwardRef((props, ref) => {
);
});

IntroductionTextarea.displayName = "IntroductionTextarea";
IntroTextarea.displayName = "IntroTextarea";

export default IntroductionTextarea;
export default IntroTextarea;
10 changes: 5 additions & 5 deletions components/SocialArticle.js → components/SocialItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React, { useContext, forwardRef } from "react";
import Image from "next/image";
import { StateContext } from "../pages/_app";
import FormLabel from "./forms/FormLabel";
import SocialInput from "./SocialInput";
import MinimalFormInput from "./forms/MinimalFormInput";

const SocialArticle = forwardRef((props, ref) => {
const SocialItem = forwardRef((props, ref) => {
const {
formLabelText,
linkPrefix,
Expand All @@ -30,7 +30,7 @@ const SocialArticle = forwardRef((props, ref) => {
<div className="flex items-center text-sm text-dark-300 bg-dark-900">
<span className="py-2 pl-2 mt-0 mb-0 leading-4">{linkPrefix}</span>
</div>
<SocialInput
<MinimalFormInput
ref={ref}
section={section}
type={account}
Expand All @@ -42,6 +42,6 @@ const SocialArticle = forwardRef((props, ref) => {
);
});

SocialArticle.displayName = "SocialArticle";
SocialItem.displayName = "SocialItem";

export default SocialArticle;
export default SocialItem;
4 changes: 2 additions & 2 deletions components/buttons/AddRepo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from "react";
import { StateContext } from "../../pages/_app";

const AddButton = ({ action, repoNumberToAdd }) => {
const AddRepo = ({ action, repoNumberToAdd }) => {
const { state, dispatch } = useContext(StateContext);
return (
<button
Expand Down Expand Up @@ -34,4 +34,4 @@ const AddButton = ({ action, repoNumberToAdd }) => {
);
};

export default AddButton;
export default AddRepo;
4 changes: 2 additions & 2 deletions components/MenuItem.js → components/buttons/MenuItem.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext } from "react";

import { ACTIONS } from "../pages/_app";
import { StateContext } from "../pages/_app";
import { ACTIONS } from "../../pages/_app";
import { StateContext } from "../../pages/_app";

const MenuItem = ({ text, section, setSidebarOpen }) => {
const { state, dispatch } = useContext(StateContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useContext } from "react";
import { StateContext } from "../pages/_app";
import { StateContext } from "../../pages/_app";

const BadgeStyleSelector = ({
const StyleBadgeButton = ({
badgeText,
handleColorToggle,
handleStyleBadge,
badgeKeyToStyle,
badgeKeyToHide,
colorList,
Expand All @@ -14,7 +14,7 @@ const BadgeStyleSelector = ({
return (
<article className={`flex flex-col`}>
<button
onClick={handleColorToggle}
onClick={handleStyleBadge}
name={badgeKeyToHide}
disabled={!badgesShowing ? true : false}
className={`border flex flex-col text-xs font-semibold uppercase border-dark-600 items-start group ${
Expand Down Expand Up @@ -84,4 +84,4 @@ const BadgeStyleSelector = ({
);
};

export default BadgeStyleSelector;
export default StyleBadgeButton;
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, { useContext } from "react";
import { StateContext } from "../pages/_app";
import { FormLabel } from "./forms/FormLabel";
import { StateContext } from "../../pages/_app";

const BadgeSelector = ({
const ToggleBadgeButton = ({
badgeType,
badgeText,
profileLink,
handleBadgeClick,
handleBadgeToggle,
}) => {
const { state, dispatch } = useContext(StateContext);
const { state } = useContext(StateContext);
return (
<label
className={`py-3 w-full flex uppercase font-semibold group select-none border border-dark-600 px-2 ${
Expand All @@ -21,7 +20,7 @@ const BadgeSelector = ({
type="checkbox"
name={badgeType}
value={state.badges[badgeType].selected}
onChange={handleBadgeClick}
onChange={handleBadgeToggle}
className="checkbox-input"
checked={state.badges[badgeType].selected}
disabled={
Expand All @@ -33,4 +32,4 @@ const BadgeSelector = ({
);
};

export default BadgeSelector;
export default ToggleBadgeButton;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useContext } from "react";
import { StateContext } from "../pages/_app";
import { StateContext } from "../../pages/_app";

const BadgeShowSelector = ({
const ToggleBadgeElementCheckbox = ({
badgeText,
handleBadgeShowClick,
handleBadgeElementToggle,
badgeKeyToHide,
}) => {
const { state, dispatch } = useContext(StateContext);
Expand All @@ -15,7 +15,7 @@ const BadgeShowSelector = ({
type="checkbox"
name={badgeKeyToHide}
value={state.badges.githubStatsCard[badgeKeyToHide]}
onChange={handleBadgeShowClick}
onChange={handleBadgeElementToggle}
className="checkbox-input"
checked={state.badges.githubStatsCard[badgeKeyToHide]}
/>
Expand All @@ -24,4 +24,4 @@ const BadgeShowSelector = ({
);
};

export default BadgeShowSelector;
export default ToggleBadgeElementCheckbox;
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { useContext, forwardRef } from "react";
import { StateContext } from "../pages/_app";
import { StateContext } from "../../pages/_app";

const SocialInput = forwardRef((props, ref) => {
const MinimalFormInput = forwardRef((props, ref) => {
const { placeholder, action, type, section } = props;
const { state, dispatch } = useContext(StateContext);
return (
<input
className="minimal-input-field"
name={type}
className="minimal-input-field appearance-none"
placeholder={placeholder}
ref={ref}
name={type}
value={state[section][type]["linkSuffix"]}
onChange={() =>
dispatch({
Expand All @@ -21,6 +21,6 @@ const SocialInput = forwardRef((props, ref) => {
);
});

SocialInput.displayName = "SocialInput";
MinimalFormInput.displayName = "MinimalFormInput";

export default SocialInput;
export default MinimalFormInput;
5 changes: 5 additions & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,11 @@ const initialState = {
linkPrefix: "https://www.codesandbox.com/",
linkSuffix: "",
},
codepen: {
path: "https://raw.githubusercontent.com/danielcranney/readme-generator/main/public/icons/socials/codepen.svg",
linkPrefix: "https://www.codepen.com/",
linkSuffix: "",
},
stackoverflow: {
path: "https://raw.githubusercontent.com/danielcranney/readme-generator/main/public/icons/socials/stackoverflow.svg",
linkPrefix: "https://www.stackoverflow.com/users/",
Expand Down
Loading

1 comment on commit 48f2218

@vercel
Copy link

@vercel vercel bot commented on 48f2218 Mar 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.