Skip to content

components(Image, Grid): components initialization#4

Merged
Stradivario merged 1 commit intomasterfrom
3-image-grid-components-initialization
Oct 15, 2019
Merged

components(Image, Grid): components initialization#4
Stradivario merged 1 commit intomasterfrom
3-image-grid-components-initialization

Conversation

@Stradivario
Copy link
Copy Markdown
Member

@Stradivario Stradivario commented Oct 15, 2019

Issue

Description

Introducing rx-grid and rx-image components

Screenshots (optional)

Screenshot from 2019-10-15 15-54-54

<div style="max-width: 200px; background-color: white">
  <rx-image
    image="https://getuikit.com/images/icon-clipboard.svg"
  ></rx-image>
  <rx-image image=${glyph} @onLoad=${this.onLoad}></rx-image>
</div>

Image Component

Basic Usage
<rx-image image="https://getuikit.com/images/icon-clipboard.svg"></rx-image>
Advanced usage

Require svg files is done by ParcelJS only typings.d.ts needs to be defined for linters in order to work correct without throwing Cannot find module './app.component.cdss'.

import { html, Component, LitElement } from '@rxdi/lit-html';
import glyph from '@rxdi/ui-kit/images/glyph.svg';

/**
 * @customElement image-view-component
 */
@Component({
  selector: 'image-view-component',
  template(this: ImageViewComponent) {
    return html`
      <rx-image image=${glyph} @onLoad=${this.onLoad}></rx-image>
      <rx-image image="https://graphql-server.com/assets/images/logo.png" @onLoad=${this.onLoad}></rx-image>
    `;
  }
})
export class ImageViewComponent extends LitElement {
  onLoad = (event: CustomEvent<HTMLImageElement>) => {
    console.log(event.target);
  }
}

Grid Component

Usage
import { html, Component, LitElement } from '@rxdi/lit-html';
import glyph from '@rxdi/ui-kit/images/glyph.svg';

/**
 * @customElement image-view-component
 */
@Component({
  selector: 'image-view-component',
  template(this: ImageViewComponent) {
    return html`
      <flex-grid
        .$items=${[
          html`
            <div>
              <h1 style="font-size: 2.75em; font-weight: 700; width: 400px; line-height: 1.25em;">
                Your Open-Source Scalable Cloud Solution
              </h1>
              <div style="height:20px;"></div>
              <h2>Get the latest from Graphql Server</h2>
              <p>Receive news, announcements, and more.</p>
            </div>
          `,
          html`
            <div style="width: 596px;">Working</div>
          `,
        ]}
      >
      </flex-grid>
    `;
  }
})
export class ImageViewComponent extends LitElement {}

Iterate over Observable or Promise items

Inside .template callback you will have ability to put your template. This callback will stop for every item provided inside .$items attribute

import { html, Component, LitElement } from '@rxdi/lit-html';

/**
 * @customElement flex-grid-view-component
 */
@Component({
  selector: 'flex-grid-view-component',
  template(this: FlexGridViewComponent) {
    return html`
      <flex-grid .$items=${[]} .template=${item => html``}></flex-grid>
    `;
  }
})
export class FlexGridViewComponent extends LitElement {}

@Stradivario Stradivario force-pushed the 3-image-grid-components-initialization branch 4 times, most recently from c3e8b6c to cfd5bae Compare October 15, 2019 13:00
@Stradivario Stradivario force-pushed the 3-image-grid-components-initialization branch from cfd5bae to 3c824a4 Compare October 15, 2019 13:01
@Stradivario Stradivario merged commit aba0b8d into master Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant