Skip to content

Commit

Permalink
feat: update the tweet content of quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Victor committed Feb 9, 2024
1 parent 771bfa0 commit c285ec2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
12 changes: 4 additions & 8 deletions src/components/inc/QuoteCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
EditIcon,
} from "@components/icons";
import { tweetHandler } from "@utils";
import { Flex, Text, Box, IconButton } from "@components/base";
import { Flex, Text, IconButton } from "@components/base";
import { Quote } from "@store/slices/QuotesSlice";
import useStore from "@store";
import { shallow } from "zustand/shallow";
Expand All @@ -23,7 +23,7 @@ export function QuoteCard(props: QuoteCardProps) {
const { id, text, author } = props.quote;
const [favouriteQuotes, setFavouriteQuotes] = useStore(
(state) => [state.favouriteQuotes, state.setFavouriteQuotes],
shallow
shallow,
);
const tweetText = `I love this quote by ${author}!
${text}”`;
Expand All @@ -33,7 +33,7 @@ export function QuoteCard(props: QuoteCardProps) {
function ToggleFavorite(quoteId: string) {
if (isFavorite(quoteId)) {
setFavouriteQuotes(
favouriteQuotes.filter((favQuote) => favQuote.id !== quoteId)
favouriteQuotes.filter((favQuote) => favQuote.id !== quoteId),
);
} else {
setFavouriteQuotes([...favouriteQuotes, props.quote]);
Expand Down Expand Up @@ -104,11 +104,7 @@ export function QuoteCard(props: QuoteCardProps) {
<IconButton
size="xs"
as="a"
href={tweetHandler(
tweetText,
["chroma", "inspring", "inspirational"],
"chroma"
)}
href={tweetHandler(tweetText)}
target="_blank"
rel="noreferrer"
>
Expand Down
6 changes: 1 addition & 5 deletions src/components/inc/widgets/Quotes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ function Quotes() {
size: 10,
},
}}
href={tweetHandler(
tweetText,
["chroma", "inspring", "inspirational"],
"chroma",
)}
href={tweetHandler(tweetText)}
target="_blank"
rel="noreferrer"
>
Expand Down
4 changes: 3 additions & 1 deletion src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ export function handleGoals() {
}
}

export function tweetHandler(text: string, hashtags: string[], via: string) {
export function tweetHandler(text: string) {
const hashtags = ["paige_devmotion", "inspring", "inspirational"];
const via = "paige_devmotion";
const baseUrl = "https://twitter.com/intent/tweet";
const url = `${baseUrl}?text=${encodeURI(
text,
Expand Down

0 comments on commit c285ec2

Please sign in to comment.