-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build a preact CDN bundle and use it in a new
cdn-preact
example
Note that the additional babel config breaks Storybook, but if we end up going this route, we can update our Storybook config to work with preact
- Loading branch information
Showing
9 changed files
with
123 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,15 @@ | ||
## Example: Consuming assets from the CDN | ||
|
||
This shows the usage of CMS design system components from the CDN: | ||
|
||
- Include the core CSS bundle and theme | ||
- Include the JS vendor files and bundle | ||
- Use CSS layout, utility, and component classes | ||
- Render React components from our library | ||
|
||
See also: https://reactjs.org/docs/add-react-to-a-website.html | ||
|
||
## Getting started | ||
|
||
1. Serve the root of this directory from a webserver, with `npx http-server` | ||
2. View it in a browser by visiting http://localhost:8080 |
This file contains 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,4 @@ | ||
#!/usr/bin/env bash | ||
|
||
mkdir -p dist/js | ||
cp -R ../../packages/design-system/dist/js/. dist/js/ |
This file contains 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,65 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>CDN Example</title> | ||
<link rel="stylesheet" href="https://design.cms.gov/cdn/design-system/6.0.0/css/index.css" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://design.cms.gov/cdn/design-system/6.0.0/css/core-theme.css" | ||
/> | ||
<link rel="stylesheet" href="style.css" /> | ||
<script src="dist/js/preact.min.umd.js"></script> | ||
<script src="dist/js/bundle.js"></script> | ||
</head> | ||
<body class="ds-base"> | ||
<div id="usa-banner"></div> | ||
<script> | ||
preact.render(preact.h(DesignSystem.UsaBanner), document.getElementById('usa-banner')); | ||
</script> | ||
|
||
<header class="ds-base--inverse ds-u-padding-y--3"> | ||
<div class="ds-l-container"> | ||
<span class="ds-h3">ExampleWebsite.gov</span> | ||
</div> | ||
</header> | ||
|
||
<div class="ds-l-container ds-u-padding-top--2"> | ||
<div class="ds-u-measure--base"> | ||
<h1 class="ds-h1">CDN Example</h1> | ||
<p> | ||
This is an example showing how to use the CDN. Some elements are simple and can be easily | ||
created by applying a CSS class from the Design System. Some components are more complex | ||
or are interactive. Our React-based component library is here for those more complex | ||
cases. | ||
</p> | ||
|
||
<div id="alert"></div> | ||
<script> | ||
preact.render( | ||
preact.h(DesignSystem.Alert, { | ||
heading: 'Hello World', | ||
children: 'I was rendered with React!', | ||
}), | ||
document.getElementById('alert') | ||
); | ||
</script> | ||
|
||
<form> | ||
<div id="month-picker"></div> | ||
<script> | ||
preact.render( | ||
preact.h(DesignSystem.MonthPicker, { | ||
label: 'Please select the months you lived abroad.', | ||
name: 'months', | ||
}), | ||
document.getElementById('month-picker') | ||
); | ||
</script> | ||
|
||
<button type="submit" class="ds-c-button ds-c-button--primary">Submit</button> | ||
</form> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains 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,4 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
} |
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
|
@@ -20459,6 +20459,11 @@ postcss@^8.2.9, postcss@^8.3.11, postcss@^8.4.12: | |
picocolors "^1.0.0" | ||
source-map-js "^1.0.2" | ||
|
||
[email protected]: | ||
version "10.11.3" | ||
resolved "https://registry.yarnpkg.com/preact/-/preact-10.11.3.tgz#8a7e4ba19d3992c488b0785afcc0f8aa13c78d19" | ||
integrity sha512-eY93IVpod/zG3uMF22Unl8h9KkrcKIRs2EGar8hwLZZDU1lkjph303V9HZBwufh2s736U6VXuhD109LYqPoffg== | ||
|
||
prebuild-install@^7.0.1: | ||
version "7.0.1" | ||
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-7.0.1.tgz#c10075727c318efe72412f333e0ef625beaf3870" | ||
|