File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .container {
2+ margin : var (--size-4 ) 0 ;
3+ padding : var (--size-4 );
4+ background-color : # e7e8ea ;
5+ border-radius : var (--radius-4 );
6+ color : var (--color-primary );
7+ font-size : var (--font-size-1 );
8+ }
9+
10+ .snippetContainer {
11+ width : 100% ;
12+ }
13+
14+ .snippet {
15+ color : var (--color-primary );
16+ border-radius : var (--radius-4 );
17+ border : var (--radius-1 ) solid # c1d3cd ;
18+ box-shadow : var (--shadow-2 );
19+ margin : var (--size-px-2 ) 0 ;
20+ text-align : center;
21+ padding : var (--size-1 );
22+ display : block;
23+ }
Original file line number Diff line number Diff line change 1+ import '../ctc-button/ctc-button.tsx' ;
2+ import styles from './banner-cta.module.css' ;
3+
4+ export default class BannerCta extends HTMLElement {
5+ static code = 'npm i -D wc-compiler' ;
6+
7+ connectedCallback ( ) {
8+ this . render ( ) ;
9+ }
10+
11+ render ( ) {
12+ return (
13+ < div class = { styles . container } >
14+ < p >
15+ WCC is a NodeJS package for easier server-rendering (SSR) of native Web Components. It can
16+ render your Web Components to static HTML supporting either Light DOM or Declarative
17+ Shadow DOM.
18+ </ p >
19+ < div class = { styles . snippetContainer } >
20+ < div class = { styles . snippet } >
21+ < pre > $ { BannerCta . code } </ pre >
22+ < wcc-ctc-button content = { BannerCta . code } > </ wcc-ctc-button >
23+ </ div >
24+ </ div >
25+ </ div >
26+ ) ;
27+ }
28+ }
29+
30+ customElements . define ( 'wcc-banner-cta' , BannerCta ) ;
Load diff This file was deleted.
Original file line number Diff line number Diff line change 1+ # icon {
2+ padding : var (--size-2 );
3+ border : none;
4+ cursor : copy;
5+ border-radius : var (--radius-3 );
6+ background-color : var (--color-green-pale );
7+ }
Original file line number Diff line number Diff line change 1+ import copy from '../../assets/copy-button.svg?type=raw' ;
2+ import sheet from './ctc-button.css' with { type : 'css' } ;
3+
4+ const template = document . createElement ( 'template' ) ;
5+
6+ template . innerHTML = `
7+ <button id="icon" title="Copy to clipboard">${ copy } </button>
8+ ` ;
9+
10+ export default class CopyToClipboardButton extends HTMLElement {
11+ connectedCallback ( ) {
12+ // bail of out of SSR entirely
13+ if ( ! this . shadowRoot && typeof window !== 'undefined' ) {
14+ this . attachShadow ( { mode : 'open' } ) ;
15+ this . shadowRoot . appendChild ( template . content . cloneNode ( true ) ) ;
16+
17+ this . shadowRoot . adoptedStyleSheets = [ sheet ] ;
18+
19+ this . shadowRoot . getElementById ( 'icon' ) ?. addEventListener ( 'click' , ( ) => {
20+ const contents = this . getAttribute ( 'content' ) ?? undefined ;
21+
22+ navigator . clipboard . writeText ( contents ) ;
23+ console . log ( 'copying the following contents to your clipboard =>' , contents ) ;
24+ } ) ;
25+ }
26+ }
27+ }
28+
29+ customElements . define ( 'wcc-ctc-button' , CopyToClipboardButton ) ;
30+
31+ declare global {
32+ namespace JSX {
33+ interface IntrinsicElements {
34+ 'wcc-ctc-button' : {
35+ content : string ;
36+ } ;
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change @@ -7,3 +7,9 @@ declare module '*?type=raw' {
77 const content : string ;
88 export default content ;
99}
10+
11+ declare module '*.css' {
12+ const sheet : CSSStyleSheet ;
13+
14+ export default sheet ;
15+ }
Original file line number Diff line number Diff line change @@ -3,12 +3,12 @@ collection: nav
33order : 1
44imports :
55 - ../components/banner-splash/banner-splash.tsx type="module" data-gwd-opt="static"
6- - ../components/banner/banner.tsx type="module" data-gwd-opt="static"
6+ - ../components/banner-cta /banner-cta .tsx type="module" data-gwd-opt="static"
77---
88
99<wcc-banner-splash ></wcc-banner-splash >
1010
11- <wcc-banner ></wcc-banner >
11+ <wcc-banner-cta ></wcc-banner-cta >
1212
1313## How It Works
1414
You can’t perform that action at this time.
0 commit comments