Skip to content

Commit 622a652

Browse files
authored
Merge pull request #3 from rocket-org-imdeepmind/feature/#2
#2: Added chnages for new Rocket
2 parents 151d940 + 8032175 commit 622a652

File tree

7 files changed

+264
-34
lines changed

7 files changed

+264
-34
lines changed

.github/workflows/eslint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ jobs:
2323
cache: "npm"
2424
- run: npm cache clean --force
2525
- run: npm ci
26-
- run: npm run eslint:check
26+
- run: npm run lint:check

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm run eslint:check
1+
npm run lint:check

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
# RocketRedoc
1+
# RedocWeb
22

3-
RocketRedoc is a hosted Redoc UI instance that allows users to visualize and interact with OpenAPI documentation. By simply passing the URL of an OpenAPI JSON schema, users can explore APIs effortlessly.
3+
RedocWeb is a hosted Redoc UI instance that allows users to visualize and interact with OpenAPI documentation. By simply passing the URL of an OpenAPI JSON schema, users can explore APIs effortlessly.
44

55
## How to Use
66

7-
To utilize RocketRedoc, follow these simple steps:
7+
To utilize RedocWeb, follow these simple steps:
88

9-
1. Navigate to [RocketRedoc](https://redoc.rocketapi.net/).
9+
1. Navigate to [RedocWeb](https://redoc.rocketapi.net/).
1010
2. Append `?url=<open_api_schema_url>` to the URL, replacing `<open_api_schema_url>` with the URL of your OpenAPI JSON schema. For example:
11+
1112
```
1213
https://redoc.rocketapi.net/?url=https://example.com/openapi.json
1314
```
@@ -18,15 +19,17 @@ You will now be directed to a Redoc UI instance displaying the documentation spe
1819

1920
## Features
2021

21-
- **Easy Visualization**: RocketRedoc provides an intuitive interface for exploring OpenAPI documentation.
22+
- **Easy Visualization**: RedocWeb provides an intuitive interface for exploring OpenAPI documentation.
2223
- **Hosted Solution**: Eliminates the need for setting up Redoc locally, making API exploration hassle-free.
2324

2425
## Contributing
26+
2527
Contributions are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request.
2628

2729
## Support
30+
2831
For any inquiries or support requests, please contact us at [email protected].
2932

3033
## License
31-
This project is licensed under the MIT License - see the LICENSE file for details.
3234

35+
This project is licensed under the MIT License - see the LICENSE file for details.

index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<link rel="preconnect" href="https://fonts.googleapis.com" />
8+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
9+
<link
10+
href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap"
11+
rel="stylesheet"
12+
/>
713
<title>Redoc | Rocket: Create Backend APIs with Ease</title>
14+
<meta
15+
name="description"
16+
content="Rocket API Redoc Documentation Viewer: Visualize and explore OpenAPI schemas for APIs built with Rocket, the no-code backend builder. Enter your OpenAPI URL to generate interactive API documentation"
17+
/>
818
</head>
919
<body>
1020
<div id="root"></div>

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
22
"name": "rocket-redoc",
33
"private": false,
4-
"version": "v1.0.0",
4+
"version": "v1.3.0",
55
"type": "module",
66
"author": "Abhishek Chatterjee",
77
"scripts": {
88
"dev": "vite",
99
"build": "tsc && vite build",
1010
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1111
"preview": "vite preview",
12-
"eslint:check": "eslint --ext tsx,ts ./src",
13-
"eslint:write": "eslint --ext tsx,ts --fix ./src",
12+
"lint:check": "eslint --ext tsx,ts ./src",
13+
"lint:write": "eslint --ext tsx,ts --fix ./src",
1414
"prepare": "husky"
1515
},
1616
"dependencies": {

public/logo.png

56.7 KB
Loading

src/App.tsx

Lines changed: 240 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,269 @@
11
import { RedocStandalone } from 'redoc'
2+
import { useState } from 'react'
23

34
import './App.css'
45

6+
const RocketLogo = (): JSX.Element => <img src="/logo.png" width={80} />
7+
58
const styles = {
9+
// Layout
610
container: {
11+
fontFamily: '"Inter", sans-serif',
12+
maxWidth: '1200px',
13+
margin: '0 auto',
14+
padding: '0 20px'
15+
},
16+
header: {
17+
display: 'flex' as const,
18+
alignItems: 'center',
19+
justifyContent: 'center',
20+
flexDirection: 'column' as const,
21+
padding: '40px 0 30px'
22+
},
23+
branding: {
24+
display: 'flex' as const,
25+
alignItems: 'center',
26+
marginBottom: '20px'
27+
},
28+
content: {
29+
display: 'flex' as const,
30+
flexDirection: 'column' as const,
31+
alignItems: 'center',
732
maxWidth: '600px',
8-
margin: 'auto',
9-
padding: '20px',
10-
backgroundColor: '#f8f9fa',
33+
margin: '0 auto 40px',
1134
textAlign: 'center' as const
1235
},
36+
card: {
37+
backgroundColor: '#f8f9fa',
38+
borderRadius: '8px',
39+
boxShadow: '0 2px 10px rgba(0,0,0,0.08)',
40+
padding: '40px',
41+
width: '100%',
42+
marginTop: '30px'
43+
},
44+
// Typography
1345
title: {
46+
fontSize: '36px',
47+
fontWeight: 600,
1448
color: '#fb2645',
15-
marginBottom: '20px'
49+
margin: '0 0 0 12px'
50+
},
51+
subTitle: {
52+
fontSize: '22px',
53+
fontWeight: 500,
54+
color: '#333',
55+
margin: '0 0 24px 0'
1656
},
1757
text: {
1858
fontSize: '16px',
19-
marginBottom: '10px'
59+
lineHeight: '24px',
60+
color: '#555',
61+
margin: '0 0 24px 0'
62+
},
63+
link: {
64+
color: '#fb2645',
65+
textDecoration: 'none',
66+
fontWeight: 500
67+
},
68+
// Form elements
69+
inputGroup: {
70+
display: 'flex' as const,
71+
width: '100%',
72+
marginTop: '20px'
73+
},
74+
input: {
75+
flex: 1,
76+
padding: '12px 16px',
77+
fontSize: '16px',
78+
borderRadius: '4px 0 0 4px',
79+
border: '1px solid #ddd',
80+
borderRight: 'none',
81+
outline: 'none',
82+
transition: 'border-color 0.2s'
83+
},
84+
button: {
85+
backgroundColor: '#fb2645',
86+
color: 'white',
87+
border: 'none',
88+
borderRadius: '0 4px 4px 0',
89+
padding: '0 24px',
90+
fontSize: '16px',
91+
fontWeight: 500,
92+
cursor: 'pointer',
93+
transition: 'background-color 0.2s'
94+
},
95+
// Special states
96+
inputFocused: {
97+
borderColor: '#fb2645'
98+
},
99+
buttonHover: {
100+
backgroundColor: '#e51e3a'
101+
},
102+
footer: {
103+
marginTop: '40px',
104+
fontSize: '14px',
105+
color: '#999'
106+
},
107+
// Banner
108+
banner: {
109+
fontFamily: '"Inter", sans-serif',
110+
backgroundColor: '#000000',
111+
color: 'white',
112+
textAlign: 'center' as const,
113+
padding: '12px 0px',
114+
width: '100%',
115+
position: 'relative' as const,
116+
zIndex: 9999,
117+
boxShadow: '0 2px 4px rgba(0,0,0,0.1)'
118+
},
119+
bannerText: {
120+
margin: 0,
121+
fontSize: '15px',
122+
color: '#fb2645'
123+
},
124+
bannerLink: {
125+
color: '#fb2645',
126+
fontWeight: 600,
127+
textDecoration: 'underline'
20128
}
21129
}
22130

23-
function App (): JSX.Element {
131+
const App = (): JSX.Element => {
132+
// State to manage URL input
133+
const [inputUrl, setInputUrl] = useState('')
134+
const [inputFocused, setInputFocused] = useState(false)
135+
const [buttonHovered, setButtonHovered] = useState(false)
136+
137+
// Handle URL from query parameters
24138
const params = window.location.search
25-
const url = params.split('=').length > 1 ? params.split('=')[1] : ''
139+
const url =
140+
params.split('=').length > 1
141+
? decodeURIComponent(params.split('=')[1])
142+
: ''
26143

144+
// Navigate to URL when form is submitted
145+
const handleSubmit = (e: React.FormEvent): void => {
146+
e.preventDefault()
147+
if (inputUrl.trim().length > 0) {
148+
window.location.href = `?url=${encodeURIComponent(inputUrl.trim())}`
149+
}
150+
}
151+
152+
// Banner component that shows when URL is present
153+
const Banner = (): JSX.Element => (
154+
<div style={styles.banner}>
155+
<p style={styles.bannerText}>
156+
Powered by{' '}
157+
<a
158+
href="https://rocketapi.net"
159+
target="_blank"
160+
rel="noopener noreferrer"
161+
style={styles.bannerLink}
162+
>
163+
Rocket
164+
</a>{' '}
165+
- Build your backend with Rocket.
166+
</p>
167+
</div>
168+
)
169+
170+
// If no URL parameter is provided, show the landing page
27171
if (url.length === 0) {
28172
return (
29-
<div style={styles.container}>
30-
<h1 style={styles.title}>Error: OpenAPI Schema URL Missing</h1>
31-
<p style={styles.text}>
32-
You need to pass the OpenAPI schema URL as a query string in the
33-
following format:
34-
</p>
35-
<p style={styles.text}>
36-
<i>https://redoc.rocketapi.net/?url=your_openapi_schema_url</i>
37-
</p>
173+
<div style={{ minHeight: '100vh' }}>
174+
<div style={styles.container}>
175+
<header style={styles.header}>
176+
<div style={styles.branding}>
177+
<RocketLogo />
178+
<h1 style={styles.title}>Rocket API</h1>
179+
</div>
180+
</header>
181+
182+
<main style={styles.content}>
183+
<h2 style={styles.subTitle}>OpenAPI Documentation Viewer</h2>
184+
<p style={styles.text}>
185+
Visualize and explore your API documentation with our Redoc UI
186+
integration. Simply enter your OpenAPI schema URL below to get
187+
started.
188+
</p>
189+
190+
<div style={styles.card}>
191+
<p style={styles.text}>Enter your OpenAPI schema URL:</p>
192+
193+
<form onSubmit={handleSubmit}>
194+
<div style={styles.inputGroup}>
195+
<input
196+
type="url"
197+
placeholder="https://example.com/openapi.json"
198+
value={inputUrl}
199+
onChange={(e) => {
200+
setInputUrl(e.target.value)
201+
}}
202+
onFocus={() => {
203+
setInputFocused(true)
204+
}}
205+
onBlur={() => {
206+
setInputFocused(false)
207+
}}
208+
style={{
209+
...styles.input,
210+
...(inputFocused ? styles.inputFocused : {})
211+
}}
212+
/>
213+
<button
214+
type="submit"
215+
onMouseEnter={() => {
216+
setButtonHovered(true)
217+
}}
218+
onMouseLeave={() => {
219+
setButtonHovered(false)
220+
}}
221+
style={{
222+
...styles.button,
223+
...(buttonHovered ? styles.buttonHover : {})
224+
}}
225+
>
226+
View Docs
227+
</button>
228+
</div>
229+
</form>
230+
</div>
231+
232+
<footer style={styles.footer}>
233+
<p>
234+
Visit{' '}
235+
<a
236+
href="https://rocketapi.net"
237+
target="_blank"
238+
rel="noopener noreferrer"
239+
style={styles.link}
240+
>
241+
rocketapi.net
242+
</a>{' '}
243+
for information.
244+
</p>
245+
<p style={{ marginTop: '10px', fontSize: '14px', color: '#666' }}>
246+
Rocket - Build your backend with Rocket.
247+
</p>
248+
</footer>
249+
</main>
250+
</div>
38251
</div>
39252
)
40253
}
41254

255+
// If URL is provided, show the Redoc UI with banner
42256
return (
43-
<RedocStandalone
44-
specUrl={url}
45-
options={{
46-
nativeScrollbars: true,
47-
theme: { colors: { primary: { main: '#fb2645' } } }
48-
}}
49-
/>
257+
<div style={{ backgroundColor: 'white', height: '100vh' }}>
258+
<Banner />
259+
<RedocStandalone
260+
specUrl={url}
261+
options={{
262+
nativeScrollbars: true,
263+
theme: { colors: { primary: { main: '#fb2645' } } }
264+
}}
265+
/>
266+
</div>
50267
)
51268
}
52269

0 commit comments

Comments
 (0)