Skip to content

Commit 252018a

Browse files
authored
Merge pull request #180 from open-sauced/beta
v1.6.0-beta.1 -> main
2 parents 8ce3724 + a1b6f01 commit 252018a

File tree

9 files changed

+170
-89
lines changed

9 files changed

+170
-89
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55

66
> All notable changes to this project will be documented in this file
77
8+
## [1.6.0-beta.1](https://github.com/open-sauced/ai/compare/v1.5.0...v1.6.0-beta.1) (2023-06-13)
9+
10+
11+
### 🍕 Features
12+
13+
* carousel design for the highlights feed ([#173](https://github.com/open-sauced/ai/issues/173)) ([0392654](https://github.com/open-sauced/ai/commit/03926540cc0ae2203d00bda69d65a40e147e1d46))
14+
815
## [1.5.0](https://github.com/open-sauced/ai/compare/v1.4.0...v1.5.0) (2023-06-06)
916

1017

npm-shrinkwrap.json

Lines changed: 30 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "opensauced-browser-extension",
33
"private": true,
4-
"version": "1.5.0",
4+
"version": "1.6.0-beta.1",
55
"files": [
66
"dist"
77
],
@@ -22,7 +22,8 @@
2222
"react-chrome-extension-router": "^1.4.0",
2323
"react-dom": "^18.0.0",
2424
"react-hot-toast": "^2.4.1",
25-
"react-icons": "^4.8.0"
25+
"react-icons": "^4.8.0",
26+
"swiper": "^9.4.0"
2627
},
2728
"devDependencies": {
2829
"@crxjs/vite-plugin": "^1.0.14",

src/popup.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,16 @@ code {
2121
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
2222
monospace;
2323
}
24+
25+
:root {
26+
--swiper-theme-color: hsla(19, 100%, 50%, 1);
27+
--swiper-pagination-top: 5px;
28+
--swiper-pagination-bullet-inactive-color: rgb(255, 159, 115);
29+
--swiper-pagination-bullet-size: 6px;
30+
--swiper-navigation-size: 18px;
31+
--swiper-navigation-sides-offset:5px;
32+
}
33+
34+
.swiper-pagination{
35+
position: relative;
36+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
interface HighlightSlideProps {
3+
highlight: {
4+
url: string;
5+
title: string;
6+
login: string;
7+
highlight: string;
8+
};
9+
}
10+
11+
export const HighlightSlide = ({ highlight }: HighlightSlideProps) => {
12+
const { url, title, login, highlight: highlightText } = highlight;
13+
14+
const openGraphSearchParameter = url.split("/").slice(3)
15+
.join("/");
16+
const openGraphUrl = `https://opengraph.githubassets.com/1/${openGraphSearchParameter}`;
17+
18+
return (
19+
<div className="border border-white/40 rounded-md p-3 mt-2 bg-white">
20+
{/* fixed height, content ellipsis */}
21+
<h3 className="
22+
text-base font-medium
23+
overflow-hidden
24+
line-clamp-2
25+
h-6
26+
leading-5
27+
"
28+
>
29+
<a
30+
className="text-slate-800 cursor-pointer"
31+
href={url}
32+
rel="noopener noreferrer"
33+
target="_blank"
34+
>
35+
{title}
36+
</a>
37+
</h3>
38+
39+
<div className="flex items-center">
40+
<span className="mr-2 text-slate-500">Author:</span>
41+
42+
<a
43+
className="text-orange cursor-pointer"
44+
href={`https://insights.opensauced.pizza/user/${login}`}
45+
rel="noopener noreferrer"
46+
target="_blank"
47+
>
48+
{login}
49+
</a>
50+
</div>
51+
52+
<p className="
53+
py-2 text-sm text-slate-500
54+
overflow-hidden
55+
line-clamp-3
56+
h-16
57+
leading-5
58+
"
59+
>
60+
{highlightText}
61+
</p>
62+
63+
<img
64+
alt="OpenGraph"
65+
src={openGraphUrl}
66+
/>
67+
68+
</div>);
69+
};

src/popup/pages/aiprdescription.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React, { useEffect, useReducer, useState } from "react";
1+
import React, { useEffect, useReducer } from "react";
22
import { FaChevronLeft } from "react-icons/fa";
33
import OpenSaucedLogo from "../../assets/opensauced-logo.svg";
4-
import { ImSwitch } from "react-icons/im";
54
import toast, { Toaster } from "react-hot-toast";
65

76
import {

src/popup/pages/home.tsx

Lines changed: 31 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import {
2-
HiArrowLeft,
3-
HiArrowRight,
42
HiArrowTopRightOnSquare,
53
HiOutlineQuestionMarkCircle,
64
HiPencil,
75
HiUserCircle,
86
} from "react-icons/hi2";
97
import { FiSettings } from "react-icons/fi";
8+
import { Navigation, Pagination, A11y } from "swiper";
9+
import { Swiper, SwiperSlide } from "swiper/react";
10+
import "swiper/swiper-bundle.min.css";
1011
import OpenSaucedLogo from "../../assets/opensauced-logo.svg";
1112
import { useAuth } from "../../hooks/useAuth";
1213
import { useOpensaucedUserCheck } from "../../hooks/useOpensaucedUserCheck";
@@ -22,13 +23,13 @@ import Settings from "./settings";
2223
import { OPEN_SAUCED_INSIGHTS_DOMAIN } from "../../constants";
2324
import type { Highlight } from "../../ts/types";
2425
import { useIsGithubPRPageCheck } from "../../hooks/useGithubPRPageCheck";
26+
import { HighlightSlide } from "../components/HighlightSlide";
2527

2628
const Home = () => {
2729
const { user } = useAuth();
2830
const { currentTabIsOpensaucedUser, checkedUser } = useOpensaucedUserCheck();
2931
const { isGithubPRPage, prUrl, prTitle } = useIsGithubPRPageCheck();
3032
const [highlights, setHighlights] = useState<Highlight[]>([]);
31-
const [currentPage, setCurrentPage] = useState(0);
3233

3334
useEffect(() => {
3435
const fetchHighlights = async () => {
@@ -49,14 +50,6 @@ const Home = () => {
4950
void fetchHighlights();
5051
}, []);
5152

52-
const handlePrevious = () => {
53-
setCurrentPage(prevPage => prevPage - 1);
54-
};
55-
56-
const handleNext = () => {
57-
setCurrentPage(prevPage => prevPage + 1);
58-
};
59-
6053
return (
6154
<div className="p-4 bg-slate-800">
6255
<div className="grid grid-cols-1 divide-y divide-white/40 divider-y-center-2 min-w-[320px] text-white">
@@ -87,76 +80,40 @@ const Home = () => {
8780
</header>
8881

8982
<main className="main-content">
90-
<h3 className="text font-medium text-base leading-10">Latest Highlight:</h3>
83+
<a
84+
className="flex items-center text-white hover:text-orange no-underline gap-2 w-full font-medium text-lg leading-10"
85+
href={`https://${OPEN_SAUCED_INSIGHTS_DOMAIN}/feed`}
86+
rel="noreferrer"
87+
target="_blank"
88+
>
89+
Highlights feed
90+
<HiArrowTopRightOnSquare />
91+
</a>
9192

9293
{highlights.length > 0 && (
94+
<Swiper
95+
navigation
96+
modules={[Navigation, Pagination, A11y]}
97+
pagination={{ clickable: true }}
98+
slidesPerView={1}
99+
spaceBetween={50}
100+
>
101+
{
102+
highlights.map((highlight, index) => (
103+
<SwiperSlide key={index}>
104+
<HighlightSlide
105+
highlight={highlight}
106+
/>
107+
</SwiperSlide>
108+
))
109+
}
110+
</Swiper>
111+
)}
93112

94-
<div className="border border-white/40 rounded-sm p-3 mt-2">
95-
<h3 className="text-base font-medium">
96-
<a
97-
className="text-blue-500 hover:text-blue-700 underline cursor-pointer"
98-
href={highlights[currentPage]?.url}
99-
rel="noopener noreferrer"
100-
target="_blank"
101-
>
102-
{highlights[currentPage]?.title}
103-
</a>
104-
</h3>
105-
106-
107-
<div className="flex items-center">
108-
<div className="mr-2">Author:</div>
109-
110-
<a
111-
className="text-blue-500 hover:text-blue-700 underline cursor-pointer"
112-
href={`https://insights.opensauced.pizza/user/${highlights[currentPage]?.login}`}
113-
rel="noopener noreferrer"
114-
target="_blank"
115-
116-
117-
>
118-
{highlights[currentPage]?.login}
119-
</a>
120-
</div>
121-
122-
<p className="py-2">
123-
{highlights[currentPage]?.highlight}
124-
</p>
125-
126-
<div className="flex justify-center">
127-
<div className="flex justify-center mt-4">
128-
<button
129-
className="px-4 py-2 rounded-md bg-blue-500 text-white disabled:opacity-50"
130-
disabled={currentPage === 0}
131-
onClick={handlePrevious}
132-
>
133-
<HiArrowLeft />
134-
</button>
135-
136-
<button
137-
className="px-4 py-2 rounded-md bg-blue-500 text-white disabled:opacity-50 ml-4"
138-
disabled={currentPage === highlights.length - 1}
139-
onClick={handleNext}
140-
>
141-
<HiArrowRight />
142-
</button>
143-
</div>
144-
</div>
145-
</div>)}
146113

147114
<h3 className="text font-medium text-base leading-10">Tools:</h3>
148115

149116
<div className="tools flex flex-col gap-2">
150-
<a
151-
className="flex items-center bg-slate-700 hover:bg-slate-700/70 text-white hover:text-orange no-underline gap-2 p-1.5 px-3 w-full rounded-sm font-medium text-sm"
152-
href={`https://${OPEN_SAUCED_INSIGHTS_DOMAIN}/feed`}
153-
rel="noreferrer"
154-
target="_blank"
155-
>
156-
<HiArrowTopRightOnSquare />
157-
Highlights feed
158-
</a>
159-
160117
<a
161118
className="flex items-center bg-slate-700 hover:bg-slate-700/70 hover:text-orange text-white gap-2 p-1.5 px-3 w-full rounded-sm font-medium text-sm"
162119
href={`https://${OPEN_SAUCED_INSIGHTS_DOMAIN}/feed`}

src/popup/pages/posthighlight.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,23 @@ const PostOnHighlight = ({ prUrl, prTitle }: { prUrl: string, prTitle: string })
1515
const [highlightContent, setHighlightContent] = useState("");
1616
const [isSendButtonEnabled, enableSendButton] = useState(true);
1717

18-
const generateAiDescription = async () => {
19-
const toastId = toast.loading("Generating summary...");
20-
18+
const generateAiDescription = () => {
2119
enableSendButton(false);
22-
const description = await getAiDescription(prUrl);
20+
const description = getAiDescription(prUrl);
2321

24-
toast.dismiss(toastId);
25-
setHighlightContent(description);
26-
enableSendButton(true);
22+
toast.promise(description, {
23+
loading: "Generating summary...",
24+
success: data => {
25+
enableSendButton(true);
26+
setHighlightContent(data);
27+
28+
return "Successfully Generated Summary";
29+
},
30+
error: e => {
31+
enableSendButton(true);
32+
return `Uh oh, there was an error! ${e.message}`;
33+
},
34+
}).catch(console.error);
2735
};
2836

2937

src/utils/fetchOpenSaucedApiData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export const updateInsight = async (userToken: string, repoId: string, checked:
181181
};
182182
export const getHighlights = async (): Promise<Highlights | undefined> => {
183183
const response = await cachedFetch(
184-
`${OPEN_SAUCED_HIGHLIGHTS_ENDPOINT}`,
184+
`${OPEN_SAUCED_HIGHLIGHTS_ENDPOINT}?limit=10`,
185185
{
186186
method: "GET",
187187
expireInSeconds: 300,

0 commit comments

Comments
 (0)