Skip to content

Commit

Permalink
Merge branch 'master' into refactor/add-react-to-project
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack authored May 8, 2019
2 parents f7a6a8b + ee65576 commit 3f6b444
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ dist
umd
css

# Netlify deploy folder
/demo/*
!/demo/index.html

# Config files
.npmrc

Expand Down
26 changes: 26 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>Deploy preview</title>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/carbon-components@latest/css/carbon-components.min.css">
<style type="text/css">
html {
height: 100%;
}

body {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}

.bx--btn {
margin: 0 0.25rem;
}
</style>
</head>
<body>
<a class="bx--btn bx--btn--primary" href="./components/">Components</a>
</body>
</html>
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"format": "prettier --write '**/*.{js,md,scss,ts}' '!**/{build,es,lib,storybook,ts,umd}/**'",
"format:diff": "prettier --list-different '**/*.{js,md,scss,ts}' '!**/{build,es,lib,storybook,ts,umd}/**'",
"format:staged": "prettier --write",
"gather-deploy-files": "yarn workspaces run gather-deploy-files",
"sync": "node tasks/sync.js"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/components/demo/js/components/RootPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class RootPage extends Component {
const hasRenderedContent =
!metadata.isCollection && subItems.length <= 1 ? metadata.renderedContent : subItems.every(item => item.renderedContent);
if (!hasRenderedContent) {
fetch(`/code/${metadata.name}`)
fetch(`./code/${metadata.name}`)
.then(checkStatus)
.then(response => response.json())
.then(responseContent => {
Expand Down Expand Up @@ -379,7 +379,7 @@ class RootPage extends Component {
const selectedNavItem = componentItems && componentItems.find(item => item.id === selectedNavItemId);
const { name } = selectedNavItem || {};
if (name) {
window.history.pushState({ name }, name, !routeWithQueryArgs ? `/demo/${name}` : `/?nav=${name}`);
window.history.pushState({ name }, name, !routeWithQueryArgs ? `./demo/${name}` : `./?nav=${name}`);
}
this._populateCurrent();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/components/demo/js/components/SideNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SideNav extends Component {
key={id}
data-nav-id={id}
isActive={id === activeItemId}
href={`/demo/${name}`}
href={`./demo/${name}`}
onClick={this.handleItemClick}>
{label}
</SideNavLink>
Expand Down
8 changes: 5 additions & 3 deletions packages/components/demo/views/layouts/demo-nav.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/">
{{#unless queryRoute}}
<base href="/">
{{/unless}}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Carbon Components</title>
Expand All @@ -15,12 +17,12 @@
overflow: hidden;
}
</style>
<link rel="stylesheet" type="text/css" href="/demo.css">
<link rel="stylesheet" type="text/css" href="./demo.css">
</head>
<body>
<div data-renderroot></div>
<input aria-label="inpute-text-offleft" type="text" class="offleft" />
{{{yield}}}
<script src="/demo{{#if minify}}.min{{/if}}.js"></script>
<script src="./demo{{#if minify}}.min{{/if}}.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions packages/components/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ const buildDemoHTML = () =>
useStaticFullRenderPage: true,
}),
minify: true,
queryRoute: true,
})
),
...componentSource
Expand Down
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"ci-check": "sh ./tools/ci-check.sh",
"dev": "gulp serve",
"format:check": "prettier --check \"**/*.{css,js,md,scss}\"",
"gather-deploy-files": "sh ./tools/deploy.sh",
"lint": "eslint .",
"lint:staged": "eslint",
"prebuild": "gulp clean",
Expand Down
27 changes: 27 additions & 0 deletions packages/components/tools/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

set -e

echo "Building carbon-components for deployment..."

# Start in tools/ even if run from root directory
cd "$(dirname "$0")"

# Go to root
cd ..

SRC_DIR=./demo
DEST_DIR=../../demo/components

yarn build-dev-rollup
rm -Rf $DEST_DIR
mkdir -p $DEST_DIR
cp -r $SRC_DIR/code $DEST_DIR/
cp -r $SRC_DIR/component $DEST_DIR/
cp $SRC_DIR/demo.css $DEST_DIR/
cp $SRC_DIR/demo.css.map $DEST_DIR/
cp $SRC_DIR/demo.min.js $DEST_DIR/
cp $SRC_DIR/feature-flags.js $DEST_DIR/
cp $SRC_DIR/index.html $DEST_DIR/

echo "Success! 🎉"

0 comments on commit 3f6b444

Please sign in to comment.