Skip to content
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

resolve multiple <slot> elements rendering on the home page #454

Merged
43 changes: 20 additions & 23 deletions www/components/card/card.css
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
:host {

& .card {
padding: 2.5rem;
position: relative;
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: initial;
text-align: center;

@media(max-width:768px) {
padding:0;
}

& .body {
padding:10px;
}
padding: 2.5rem;
position: relative;
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: initial;
text-align: center;

@media (max-width: 768px) {
padding: 0;
}

& slot {
padding: 10px;
margin: 0.25rem;
flex: 1 1 33.333%;
}

& .card-xs {
margin: 0.25rem;
Expand All @@ -30,6 +28,7 @@
max-width: 100%;
}
}

& .card-sm {
margin: 0.25rem;
flex: 1 1 25%;
Expand All @@ -39,6 +38,7 @@
max-width: 100%;
}
}

& .card-md {
margin: 0.25rem;
flex: 1 1 33.333%;
Expand All @@ -48,15 +48,12 @@
max-width: 100%;
}
}
& .card-full {
margin: 0.25rem;
flex: 1 1 33.333%;
}

& .card-img-top {
background-size: cover;
background-position-x: center;
background-position-y: center;

& img {
width: 100%;
max-width: 200px;
Expand Down
13 changes: 3 additions & 10 deletions www/components/card/card.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,9 @@ class Card extends LitElement {

render() {
return html`
<style>
${css}
</style>
<div class="card ${this.size ? `card-${this.size}` : ''}">
${this.renderImage()}
${this.renderTitle()}
<div class="body">
<slot></slot>
</div>
</div>
${this.renderImage()}
${this.renderTitle()}
<slot name="cardcontent"></slot>
`;
}
}
Expand Down
19 changes: 0 additions & 19 deletions www/components/row/row.js

This file was deleted.

17 changes: 16 additions & 1 deletion www/pages/docs/component-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,19 @@ customElements.define('x-greeting', GreetingComponent);

## References
- [MDN Developer Docs: Web Components](https://developer.mozilla.org/en-US/docs/Web/Web_Components)
- [Google Developer Docs: Web Components](https://developers.google.com/web/fundamentals/web-components/)
- [Google Developer Docs: Web Components](https://developers.google.com/web/fundamentals/web-components/)


> Some notes / recommendations about ShadowDOM from [our research](https://github.com/ProjectEvergreen/greenwood/pull/454)
> - [`<slot>` should be named](https://github.com/Polymer/lit-element/issues/824#issuecomment-535574662)
> - `<slot>` only supports a [shallow (one) level of nesting](https://javascript.info/slots-composition). A `<slot>` tag must be within a direct descendant of its `:host`.
> ```html
> <h3>Content from inside the custom element. (inside HTMLElement)</h3>
> <h3>
> <slot name="content"></slot> <!-- will show -->
> <h3>
> <div>
> <h3>
> <slot name="content"></slot> <!-- wont show -->
> <h3>
> </div>
29 changes: 14 additions & 15 deletions www/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

<!-- TODO these came from front matter, return to frontmatter? -->
<script type="module" src="../components/card/card.js"></script>
<script type="module" src="../components/row/row.js"></script>

<!-- TODO had to handle relative path by using / , should be transparent to the user -->
<link rel="stylesheet" href="/styles/home.css"></link>
Expand All @@ -16,6 +15,7 @@
<body>

<div class="gwd-content-outlet">

<app-banner></app-banner>

<div class='gwd-content-wrapper'>
Expand All @@ -28,21 +28,20 @@ <h2>Greenwood is a modern and performant static site generator for Web Component
<p>Greenwood is focused on providing an intuitive and accessible development workflow supporting modern JavaScript and CSS features like Web Components, FlexBox, CSS Grid, and Modules. Greenwood strives to deliver not only great user experiences, but also great developer experiences. To learn more about the project we encourage everyone to first go through our <a href="/getting-started/">Getting Started</a> guide. You can learn more about the project itself at our <a href="/about">about page</a> or see our <a href="/docs/">documentation</a> to learn more about how to use Greenwood.</p>
<hr/>
</div>

<div class="cards">
<app-row>
<app-card title="webpack" img="../assets/webpack.svg" size="full" style="width:100%">
To us, webpack is more than a module bundler, it's an entire development ecosystem! We use webpack
under the hood to power the development workflow and to help generate a performant site for you with the power of tools like Babel and PostCSS. The best part? You don't have to know anything about that! Greenwood handles all the configuration and optimizations for you, so you can be sure that your users will get the best experience possible, and as a developer, so will you.
</app-card>
<app-card title="Web Components" img="../assets/webcomponents.svg" size="full" style="width:100%">
Do we love Web Components? You bet we do! In fact, it's one of many things we love about the modern web, including other features like Modules, FlexBox and CSS Grid, Fetch API, and more! It's all there for you in the browser, and with Greenwood, we make sure all those features will work for all your users. Sit back and write the modern code you want and Greenwood will take care of the rest.
</app-card>
<app-card title="NodeJS" img="../assets/nodejs.png" size="full" style="width:100%">
Although Greenwood generates a static site that you can host just about anywhere (Netlify, S3, Apache, etc), for developing and building your site Greenwood requires NodeJS to be available on the command line. This allows us to tap into all the amazing web development tools and libraries available on npm and also means you can use those packages too when developing your own site! Greenwood will aim to support the latest LTS release of NodeJS and the version of npm that comes with.
</app-card>
</app-row>
</div>
<app-card title="webpack" img="../assets/webpack.svg" style="width:100%">
<p slot="cardcontent">To us, webpack is more than a module bundler, it's an entire development ecosystem! We use webpack under the hood to power the development workflow and to help generate a performant site for you with the power of tools like Babel and PostCSS. The best part? You don't have to know anything about that! Greenwood handles all the configuration and optimizations for you, so you can be sure that your users will get the best experience possible, and as a developer, so will you.</p>
</app-card>

<app-card title="Web Components" img="../assets/webcomponents.svg" style="width:100%">
<p slot="cardcontent">Do we love Web Components? You bet we do! In fact, it's one of many things we love about the modern web, including other features like Modules, FlexBox and CSS Grid, Fetch API, and more! It's all there for you in the browser, and with Greenwood, we make sure all those features will work for all your users. Sit back and write the modern code you want and Greenwood will take care of the rest.</p>
</app-card>

<app-card title="NodeJS" img="../assets/nodejs.png" style="width:100%">
<p slot="cardcontent">Although Greenwood generates a static site that you can host just about anywhere (Netlify, S3, Apache, etc), for developing and building your site Greenwood requires NodeJS to be available on the command line. This allows us to tap into all the amazing web development tools and libraries available on npm and also means you can use those packages too when developing your own site! Greenwood will aim to support the latest LTS release of NodeJS and the version of npm that comes with.</p>
</app-card>
</div>

</div>

Expand Down
12 changes: 12 additions & 0 deletions www/styles/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,16 @@ h3 {
@media(max-width:768px) {
padding:0;
}
}

.cards {
margin-left: -0.25rem;
margin-right: -0.25rem;
display: flex;
justify-content: space-around;
flex-direction: row;

@media (max-width: 1024px) {
flex-direction: column;
}
}