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

extendable app templates #356

Closed
1 of 5 tasks
thescientist13 opened this issue May 31, 2020 · 0 comments · Fixed by #382
Closed
1 of 5 tasks

extendable app templates #356

thescientist13 opened this issue May 31, 2020 · 0 comments · Fixed by #382
Assignees
Labels
breaking CLI enhancement Improve something existing (e.g. no docs, new APIs, etc)
Milestone

Comments

@thescientist13
Copy link
Member

thescientist13 commented May 31, 2020

Type of Change

  • New Feature Request
  • Documentation / Website
  • Improvement / Suggestion
  • Bug
  • Other (please clarify below)

Summary

As evidenced in the PR for code splitting there are some rough developer ergonomics around having to extend app-template.js, in that you have recreate (copy / paste) the entire file. Even if all you want to make is a little change like this

<!-- current template -->
<div class='wrapper'>
  MYROUTES
  <lit-route><h1>404 Not found</h1></lit-route>
</div>

<!-- just to add a heater and a footer -->
<div class='wrapper'>
  <eve-header></eve-header>
  MYROUTES
  <lit-route><h1>404 Not found</h1></lit-route>
  <eve-footer></eve-footer>
</div>

Details

I wonder if there's a way to do one of the following?

Extend

Simple extend the component and override the render method

import { html } from 'lit-html';
import { AppComponent } from `@greenwood/cli/src/templates/app-component';

class GreenwoodAppComponent extends AppComponent {

  render() {
    return html`
      <div class='wrapper'>
        <eve-header></eve-header>
        MYROUTES
        <lit-route><h1>404 Not found</h1></lit-route>
        <eve-footer></eve-footer>
      </div>
    `;
  }
}

Note I tried this and was getting errors that /index.index.js couldn't be resolved, likely because the app-template is in the user directory, not CLI directory?

Slots

Maybe allow users to project / slot content into the `?

import { html } from 'lit-html';
import `@greenwood/cli/src/templates/app-component';

class GreenwoodAppComponent {

  render() {
    return html`
      <app-template>
        <div class='wrapper'>
          <eve-header></eve-header>
          MYROUTES
          <lit-route><h1>404 Not found</h1></lit-route>
          <eve-footer></eve-footer>
        </div>
      </app-template>
    `;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking CLI enhancement Improve something existing (e.g. no docs, new APIs, etc)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants