-
Notifications
You must be signed in to change notification settings - Fork 51
feat: add home page #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TusharThakur04
wants to merge
3
commits into
webpack:main
Choose a base branch
from
TusharThakur04:feat/home-page
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: add home page #149
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,214 @@ | ||
| import { useState } from 'react'; | ||
|
|
||
| import styles from './index.module.css'; | ||
|
|
||
| import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; | ||
| import { vscDarkPlus } from 'react-syntax-highlighter/dist/esm/styles/prism'; | ||
|
|
||
| export default function ConfigSection() { | ||
| const [activeSyntax, setActiveSyntax] = useState('js'); | ||
|
|
||
| const jsCode = `// webpack.config.js | ||
| const path = require('path'); | ||
|
|
||
| module.exports = { | ||
| entry: './src/index.js', | ||
| output: { | ||
| filename: 'bundle.js', | ||
| path: path.resolve(__dirname, 'dist') | ||
| }, | ||
| mode: 'production' | ||
| };`; | ||
|
|
||
| const mjsCode = `// webpack.config.mjs | ||
| import path from 'path'; | ||
|
|
||
| export default { | ||
| entry: './src/index.js', | ||
| output: { | ||
| filename: 'bundle.js', | ||
| path: path.resolve(import.meta.dirname, 'dist') | ||
| }, | ||
| mode: 'production' | ||
| };`; | ||
|
|
||
| const tsCode = `// webpack.config.ts | ||
| import path from 'path'; | ||
| import { Configuration } from 'webpack'; | ||
|
|
||
| const config: Configuration = { | ||
| entry: './src/index.ts', | ||
| output: { | ||
| filename: 'bundle.js', | ||
| path: path.resolve(__dirname, 'dist') | ||
| }, | ||
| mode: 'production' | ||
| }; | ||
|
|
||
| export default config;`; | ||
|
|
||
| const [isCopied, setIsCopied] = useState(false); | ||
|
|
||
| const handleCopy = async () => { | ||
| const textToCopy = | ||
| activeSyntax === 'js' | ||
| ? jsCode | ||
| : activeSyntax === 'mjs' | ||
| ? mjsCode | ||
| : tsCode; | ||
|
|
||
| try { | ||
| await navigator.clipboard.writeText(textToCopy); | ||
| setIsCopied(true); | ||
|
|
||
| setTimeout(() => { | ||
| setIsCopied(false); | ||
| }, 2000); | ||
| } catch (err) { | ||
| console.error('Failed to copy code: ', err); | ||
| } | ||
| }; | ||
|
|
||
| const configFeatures = [ | ||
| 'Zero-config for common setups', | ||
| 'Tree-shaking out of the box', | ||
| 'Hot Module Replacement', | ||
| 'Long-term caching with content hashes', | ||
| ]; | ||
| return ( | ||
| <section className={styles.configSection}> | ||
| <div className={styles.container}> | ||
| <div className={styles.configHeader}> | ||
| <p className={styles.preTitle}>CONFIGURATION</p> | ||
| <h2 className={styles.title}> | ||
| Sensible defaults. Configurable when you need it. | ||
| </h2> | ||
| <p className={styles.subtext}> | ||
| A single config file is enough for most projects. Compose loaders to | ||
| transform any input; reach for plugins when behavior is non-trivial. | ||
| </p> | ||
| </div> | ||
|
|
||
| <div className={styles.configGrid}> | ||
| <div className={styles.codeWindow}> | ||
| <div className={styles.codeTabs}> | ||
| <button | ||
| onClick={() => setActiveSyntax('js')} | ||
| className={ | ||
| activeSyntax === 'js' ? styles.activeTab : styles.inactiveTab | ||
| } | ||
| > | ||
| webpack.config.js | ||
| </button> | ||
| <button | ||
| onClick={() => setActiveSyntax('mjs')} | ||
| className={ | ||
| activeSyntax === 'mjs' ? styles.activeTab : styles.inactiveTab | ||
| } | ||
| > | ||
| webpack.config.mjs | ||
| </button> | ||
| <button | ||
| onClick={() => setActiveSyntax('ts')} | ||
| className={ | ||
| activeSyntax === 'ts' ? styles.activeTab : styles.inactiveTab | ||
| } | ||
| > | ||
| webpack.config.ts | ||
| </button> | ||
| </div> | ||
|
|
||
| <div className={styles.codeBody}> | ||
| jsx | ||
| <SyntaxHighlighter | ||
| language={activeSyntax === 'ts' ? 'typescript' : 'javascript'} | ||
| style={vscDarkPlus} | ||
| customStyle={{ | ||
| backgroundColor: 'transparent', | ||
| margin: 0, | ||
| padding: 0, | ||
| }} | ||
| > | ||
| {activeSyntax === 'js' | ||
| ? jsCode | ||
| : activeSyntax === 'mjs' | ||
| ? mjsCode | ||
| : tsCode} | ||
| </SyntaxHighlighter> | ||
| </div> | ||
|
|
||
| <div className={styles.codeFooter}> | ||
| <span className={styles.codeLang}>JavaScript</span> | ||
| <button className={styles.copyBtn} onClick={handleCopy}> | ||
| {isCopied ? ( | ||
| <> | ||
| <svg | ||
| className={styles.checkmarkSVG} | ||
| fill="none" | ||
| stroke="currentColor" | ||
| viewBox="0 0 24 24" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| strokeWidth="2" | ||
| d="M5 13l4 4L19 7" | ||
| ></path> | ||
| </svg> | ||
| Copied! | ||
| </> | ||
| ) : ( | ||
| <> | ||
| <svg | ||
| className={styles.copySVG} | ||
| fill="none" | ||
| stroke="currentColor" | ||
| viewBox="0 0 24 24" | ||
| xmlns="http://www.w3.org/2000/svg" | ||
| > | ||
| <path | ||
| strokeLinecap="round" | ||
| strokeLinejoin="round" | ||
| strokeWidth="2" | ||
| d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" | ||
| ></path> | ||
| </svg> | ||
| Copy to clipboard | ||
| </> | ||
| )} | ||
| </button> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className={styles.features}> | ||
| <h3 className={styles.featuresTitle}>Loaders for any input</h3> | ||
| <p className={styles.featuresText}> | ||
| Through loaders, modules can be CommonJS, AMD, ES6 modules, CSS, | ||
| Images, JSON, Coffeescript, LESS — and your custom stuff. | ||
| </p> | ||
|
|
||
| <ul className={styles.checkList}> | ||
| {configFeatures.map((feature, index) => ( | ||
| <li key={index} className={styles.checkItem}> | ||
| <svg | ||
| className={styles.checkIcon} | ||
| viewBox="0 0 20 20" | ||
| fill="currentColor" | ||
| > | ||
| <path | ||
| fillRule="evenodd" | ||
| d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" | ||
| clipRule="evenodd" | ||
| /> | ||
| </svg> | ||
| {feature} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </section> | ||
| ); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than adding a needless dependency, I've opened nodejs/doc-kit#845 to allow us to supply this via Markdown.