Skip to content

docs(parcel) Add bootstrap v5 parcel examples #245

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add bootstrap v5 parcel examples and fix compiler error due to deprec…
…ated jumbotron
  • Loading branch information
lcheunglci committed Oct 22, 2021
commit 73799d40380cad685ab55260a377b6fd28ea8d72
20 changes: 20 additions & 0 deletions parcel-ts-v5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "parcel-ts",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"start": "parcel src/index.html",
"build": "parcel build src/index.html",
"test": "echo \"no tests exists\""
},
"dependencies": {
"bootstrap": "^5.1.3",
"react": "^17.0.2",
"react-bootstrap": "^2.0.0",
"react-dom": "^17.0.2"
},
"devDependencies": {
"parcel-bundler": "^1.12.5",
"typescript": "^4.4.4"
}
}
12 changes: 12 additions & 0 deletions parcel-ts-v5/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">

<head>
</head>

<body>
<div id="root"></div>
<script src="./index.tsx"></script>
</body>

</html>
42 changes: 42 additions & 0 deletions parcel-ts-v5/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { useState } from 'react';
import ReactDOM from 'react-dom';

// Importing the Bootstrap CSS
import 'bootstrap/dist/css/bootstrap.min.css';

import Toast from 'react-bootstrap/Toast';
import Container from 'react-bootstrap/Container';
import Button from 'react-bootstrap/Button';

const ExampleToast: React.FunctionComponent = ({ children }) => {
const [show, toggleShow] = useState(true);

return (
<>
{!show && <Button onClick={() => toggleShow(true)}>Show Toast</Button>}
<Toast show={show} onClose={() => toggleShow(false)}>
<Toast.Header>
<strong className="mr-auto">React-Bootstrap</strong>
</Toast.Header>
<Toast.Body>{children}</Toast.Body>
</Toast>
</>
);
};

const App = () => (
<Container className="p-3">
<Container className="p-5 mb-4 bg-light rounded-3">
<h1 className="header">Welcome To React-Bootstrap</h1>
<ExampleToast>
We now have Toasts
<span role="img" aria-label="tada">
🎉
</span>
</ExampleToast>
</Container>
</Container>
);

const mountNode = document.getElementById('root');
ReactDOM.render(<App />, mountNode);
6 changes: 6 additions & 0 deletions parcel-ts-v5/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"jsx": "react",
"esModuleInterop": true
}
}
5,492 changes: 5,492 additions & 0 deletions parcel-ts-v5/yarn.lock

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions parcel-v5/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "parcel",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"start": "parcel src/index.html",
"build": "parcel build src/index.html",
"test": "echo \"no tests exists\""
},
"dependencies": {
"bootstrap": "^5.1.3",
"react": "^17.0.2",
"react-bootstrap": "^2.0.0",
"react-dom": "^17.0.2"
},
"devDependencies": {
"parcel-bundler": "^1.12.5"
}
}
9 changes: 9 additions & 0 deletions parcel-v5/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div id="root"></div>
<script src="./index.js"></script>
</body>
</html>
42 changes: 42 additions & 0 deletions parcel-v5/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React, { useState } from 'react';
import ReactDOM from 'react-dom';

// Importing the Bootstrap CSS
import 'bootstrap/dist/css/bootstrap.min.css';

import Toast from 'react-bootstrap/Toast';
import Container from 'react-bootstrap/Container';
import Button from 'react-bootstrap/Button';

const ExampleToast = ({ children }) => {
const [show, toggleShow] = useState(true);

return (
<React.Fragment>
{!show && <Button onClick={() => toggleShow(true)}>Show Toast</Button>}
<Toast show={show} onClose={() => toggleShow(false)}>
<Toast.Header>
<strong className="mr-auto">React-Bootstrap</strong>
</Toast.Header>
<Toast.Body>{children}</Toast.Body>
</Toast>
</React.Fragment>
);
};

const App = () => (
<Container className="p-3">
<Container className="p-5 mb-4 bg-light rounded-3">
<h1 className="header">Welcome To React-Bootstrap</h1>
<ExampleToast>
We now have Toasts
<span role="img" aria-label="tada">
🎉
</span>
</ExampleToast>
</Container>
</Container>
);

var mountNode = document.getElementById('root');
ReactDOM.render(<App />, mountNode);
Loading