I just started with Polymer and I'm using paper-icon-button to test this out. I think I set things up correctly because the button I used have ripple effect; when I set the src property, my intended picture showed up.
<!-- This works -->
<paper-icon-button src="http://placekitten.org/g/50/50"></paper-icon-button>
However, I failed to use default icon, for example:
<!-- This does not work. There is a blank icon.
However, ripple effect still works on click -->
<paper-icon-button icon="menu"></paper-icon-button>
I ran the polymer project on a Linux server. The demo doesn't work on my computer either. Here is what the demo should look like: https://elements.polymer-project.org/elements/paper-icon-button?view=demo:demo/index.html
Here is the demo running on my polyserve:
I setup paper-icon-button using bower command instead of zip file so I would assume that all the dependencies are there. Not sure what is missing :s please help me out thanks!
You also need to import iron-icons. Look at this demo
and this example repository.
Proper way to initialize project on Windows:
Install yarn
open git bash
mkdir -p /c/projects/polymer && cd /c/projects/polymer
yarn add --dev bower
./node_modules/.bin/bower init
If you see: "bower ENOINT Register requires an interactive shell" run above command in cmd.exe. More.
./node_modules/.bin/bower install --save PolymerElements/iron-icons
./node_modules/.bin/bower install --save PolymerElements/paper-icon-button
Create index.html with content at the end of this post
yarn add --dev http-server
./node_modules/http-server
Open http://127.0.0.1:8080 in web browser
index.html:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<script src="/bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="/bower_components/iron-icons/iron-icons.html">
<link rel="import" href="/bower_components/paper-icon-button/paper-icon-button.html">
</head>
<body>
<paper-icon-button icon="favorite" title="heart"></paper-icon-button>
</body>
</html>
Related
How do i host the browser build?
I do not get it, i run:
npx shadow-cljs release app
npm start?
node app.js is wrong
I cannot launch app.js in the browser. What am i doing wrong?
My shadow-cljs.edn looks like this:
{:source-paths ["src"]
:dependencies [[binaryage/devtools "1.0.6"]
[nrepl "0.9.0"]
[reagent "1.1.1"]]
:builds {:app {:target :browser
:output-dir "public/js"
:asset-path "/js"
:modules {:app {:entries [simpletodo.core]}}
:devtools {:after-load simpletodo.core/mount-root}}}
:dev-http {3000 {:root "public"
:handler user/app}}}
One level higher, i would think the index.html could be the right one, but it looks like this.
I even put in this HTML file and started the HTML, but it would not work. All i get is a white page:
➜ simpletodo cat index.html
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/css/main.css">
<title>Browser Starter</title>
</head>
<body>
<h1>shadow-cljs - Browser</h1>
<div id="app"></div>
<noscript>You need to enable JavaScript to run this app.</noscript>
<script src="/public/js/app.js"></script>
</body>
</html>
Can you clarify what you mean by "hosting the build"?
If you are just testing stuff you can run npx shadow-cljs server (and keep it running) which will also run the :dev-http servers in the build config. So your files would be accessible via http://localhost:3000, just like they would be with a running watch.
A release build produces an optimized .js file. shadow-cljs is not used in production environments and is out of the picture after producing the files.
Any webserver capable of serving static files will work at that point. Common options include nginx, apache or just a CLJ webserver (eg. jetty).
As you know, technology was introduced as pyscript for the use of Python by html.
if you do not know: What is pyscript?
how do config that in xampp?
Quote from pyscript.net
You don't need to install anything. 😃
To use PyScript you can either download it and follow the
instructions, or add the following lines to your page.
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css"/>
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
Click here for more info on how to use PyScript.
If you don't need MySQL you can serve your DocumentRoot even without XAMPP using python itself or any other lightweight webserver:
python3 -m http.server
Then start with a simple html file. PyScript will fetch and cache its needed dependencies automatically:
<html>
<meta charset="utf-8">
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-script>
print('Hello World! 🌍')
</py-script>
</html>
I just installed this Create React Apps program from here https://github.com/facebookincubator/create-react-app and I have all the files downloaded and I am able to edit the App.js file, but I already have made some html files for a website, I want to know how to link the App.js file to my current files. The html on the given Index.html, shows no <script> element used. Here is the full html code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Inside your project run
npm run build
This create the folder "/build" with the "index.html" file. Inside this you can see how all this magic is done. You can put your other/old stuff also there.
I'm not entirely sure what you are asking, but you can have normal html/css on the same page as React. React is rendering the App component in the div id="root" section of the page. Elsewhere, you can just paste your old html stuff and it should work.
I've got a custom Polymer element polymer install element call it <x-custom-element> once created i'm unable to polymer serve until I change the links to reference the bower components in the elements folder.
When I publish the element to my git repository I need to change the references in the elements <links rel="import" href="bower_components/"> tohref="../` or what ever the link is to use the bower_components folder form the directory that install the element.
For example to be able to serve the file via polymer serve, with this file structure
bower.json
bower_components/
test/
temo/
x-custom-element.html
The links in x-custom-element.html need to refer to /bower_components/*
But to be able to be usable as a bower import I must change the references to ../*
Is there anyway to remedy this process? How should you approach this problem.
Create a script to change all the link back and forth?
What other options do I have?
Your example project directory is missing index.html in the root. This should be automatically generated by polymer-cli (i.e., polymer init element), and it should look like this:
<!doctype html>
<html>
<head>
<title>x-foo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="../iron-component-page/iron-component-page.html">
</head>
<body>
<iron-component-page src="x-foo.html"></iron-component-page>
</body>
</html>
I didn't have any problems viewing the site with polymer serve -o after generating the element project with polymer init element (polymer-cli v0.16.0, polyserve v0.13.0, macOS Sierra 10.12).
After doing:
cd polymer-starter-kit-1.0.3
npm install -g gulp bower && npm install && bower install
gulp serve
How do you browse to and view an element's demo page, such as:
http://localhost:3000/bower_components/paper-input/demo/
When viewing the source of the URL above, it shows the paths to be relative to the demo directory, in the form of:
<link rel="stylesheet" href="styles/main.css">
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
<link rel="import" href="elements/elements.html">
What do you need to do to make the paths resolve properly?
Include index.html at the end of the URL.
http://localhost:3000/bower_components/paper-input/demo/index.html