From 813dad3cfa1f10cd602f1fe7732d66ebfaaf91b2 Mon Sep 17 00:00:00 2001
From: Billy Surya
Date: Wed, 23 Aug 2023 17:00:19 +0700
Subject: [PATCH 1/7] feat(kompas-metered-register): generate initial component
---
.../kompas-metered-register.css | 30 +++++++++++++++++++
.../kompas-metered-register.e2e.ts | 11 +++++++
.../kompas-metered-register.spec.tsx | 18 +++++++++++
.../kompas-metered-register.tsx | 16 ++++++++++
4 files changed, 75 insertions(+)
create mode 100644 src/components/kompas-metered-register/kompas-metered-register.css
create mode 100644 src/components/kompas-metered-register/kompas-metered-register.e2e.ts
create mode 100644 src/components/kompas-metered-register/kompas-metered-register.spec.tsx
create mode 100644 src/components/kompas-metered-register/kompas-metered-register.tsx
diff --git a/src/components/kompas-metered-register/kompas-metered-register.css b/src/components/kompas-metered-register/kompas-metered-register.css
new file mode 100644
index 0000000..57c42fb
--- /dev/null
+++ b/src/components/kompas-metered-register/kompas-metered-register.css
@@ -0,0 +1,30 @@
+.body {
+ position: sticky;
+ top: 0;
+ height: 100%;
+ width: 100%;
+}
+
+.bg--gray {
+ background-color: #f4f4f4;
+ opacity: 1;
+}
+
+.icon {
+ @apply h-3 w-3;
+
+ &.lg {
+ @apply h-6;
+
+ & svg {
+ @apply h-6;
+ }
+ }
+
+ &-brand-1 {
+ @apply text-brand-1;
+ & svg {
+ @apply fill-current;
+ }
+ }
+}
diff --git a/src/components/kompas-metered-register/kompas-metered-register.e2e.ts b/src/components/kompas-metered-register/kompas-metered-register.e2e.ts
new file mode 100644
index 0000000..39898d9
--- /dev/null
+++ b/src/components/kompas-metered-register/kompas-metered-register.e2e.ts
@@ -0,0 +1,11 @@
+import { newE2EPage } from '@stencil/core/testing';
+
+describe('kompas-metered-register', () => {
+ it('renders', async () => {
+ const page = await newE2EPage();
+ await page.setContent(' ');
+
+ const element = await page.find('kompas-metered-register');
+ expect(element).toHaveClass('hydrated');
+ });
+});
diff --git a/src/components/kompas-metered-register/kompas-metered-register.spec.tsx b/src/components/kompas-metered-register/kompas-metered-register.spec.tsx
new file mode 100644
index 0000000..820a0fe
--- /dev/null
+++ b/src/components/kompas-metered-register/kompas-metered-register.spec.tsx
@@ -0,0 +1,18 @@
+import { newSpecPage } from '@stencil/core/testing';
+import { KompasMeteredRegister } from './kompas-metered-register';
+
+describe('kompas-metered-register', () => {
+ it('renders', async () => {
+ const page = await newSpecPage({
+ components: [KompasMeteredRegister],
+ html: ` `,
+ });
+ expect(page.root).toEqualHtml(`
+
+
+
+
+
+ `);
+ });
+});
diff --git a/src/components/kompas-metered-register/kompas-metered-register.tsx b/src/components/kompas-metered-register/kompas-metered-register.tsx
new file mode 100644
index 0000000..b3f5a5a
--- /dev/null
+++ b/src/components/kompas-metered-register/kompas-metered-register.tsx
@@ -0,0 +1,16 @@
+import { Component, Host, h } from '@stencil/core';
+
+@Component({
+ tag: 'kompas-metered-register',
+ styleUrl: 'kompas-metered-register.css',
+ shadow: true,
+})
+export class KompasMeteredRegister {
+ render() {
+ return (
+
+
+
+ );
+ }
+}
From 1b1985d0310550e0fb0495ac49ad4c1e0e431f0c Mon Sep 17 00:00:00 2001
From: Billy Surya
Date: Wed, 23 Aug 2023 18:38:06 +0700
Subject: [PATCH 2/7] feat(kompas-metered-register): add template for last
article
---
src/components.d.ts | 21 ++
.../kompas-metered-register.tsx | 100 ++++++-
src/index.html | 249 ++++++++++--------
tailwind.config.js | 29 +-
4 files changed, 273 insertions(+), 126 deletions(-)
diff --git a/src/components.d.ts b/src/components.d.ts
index fff5671..2fb5416 100644
--- a/src/components.d.ts
+++ b/src/components.d.ts
@@ -227,6 +227,12 @@ export namespace Components {
*/
"userInitialName": string;
}
+ interface KompasMeteredRegister {
+ /**
+ * prop countdownArticle untuk menghandle sudah berapa artikel gratis yang user baca.
+ */
+ "countdownArticle": number;
+ }
interface KompasPaywall {
"countdownArticle": number;
"isLogin": boolean;
@@ -388,6 +394,12 @@ declare global {
prototype: HTMLKompasHeaderAccountProfileElement;
new (): HTMLKompasHeaderAccountProfileElement;
};
+ interface HTMLKompasMeteredRegisterElement extends Components.KompasMeteredRegister, HTMLStencilElement {
+ }
+ var HTMLKompasMeteredRegisterElement: {
+ prototype: HTMLKompasMeteredRegisterElement;
+ new (): HTMLKompasMeteredRegisterElement;
+ };
interface HTMLKompasPaywallElement extends Components.KompasPaywall, HTMLStencilElement {
}
var HTMLKompasPaywallElement: {
@@ -437,6 +449,7 @@ declare global {
"kompas-header-account-help-center": HTMLKompasHeaderAccountHelpCenterElement;
"kompas-header-account-menu": HTMLKompasHeaderAccountMenuElement;
"kompas-header-account-profile": HTMLKompasHeaderAccountProfileElement;
+ "kompas-metered-register": HTMLKompasMeteredRegisterElement;
"kompas-paywall": HTMLKompasPaywallElement;
"kompas-paywall-banner-registration": HTMLKompasPaywallBannerRegistrationElement;
"kompas-paywall-body": HTMLKompasPaywallBodyElement;
@@ -666,6 +679,12 @@ declare namespace LocalJSX {
*/
"userInitialName"?: string;
}
+ interface KompasMeteredRegister {
+ /**
+ * prop countdownArticle untuk menghandle sudah berapa artikel gratis yang user baca.
+ */
+ "countdownArticle"?: number;
+ }
interface KompasPaywall {
"countdownArticle"?: number;
"isLogin"?: boolean;
@@ -766,6 +785,7 @@ declare namespace LocalJSX {
"kompas-header-account-help-center": KompasHeaderAccountHelpCenter;
"kompas-header-account-menu": KompasHeaderAccountMenu;
"kompas-header-account-profile": KompasHeaderAccountProfile;
+ "kompas-metered-register": KompasMeteredRegister;
"kompas-paywall": KompasPaywall;
"kompas-paywall-banner-registration": KompasPaywallBannerRegistration;
"kompas-paywall-body": KompasPaywallBody;
@@ -790,6 +810,7 @@ declare module "@stencil/core" {
"kompas-header-account-help-center": LocalJSX.KompasHeaderAccountHelpCenter & JSXBase.HTMLAttributes;
"kompas-header-account-menu": LocalJSX.KompasHeaderAccountMenu & JSXBase.HTMLAttributes;
"kompas-header-account-profile": LocalJSX.KompasHeaderAccountProfile & JSXBase.HTMLAttributes;
+ "kompas-metered-register": LocalJSX.KompasMeteredRegister & JSXBase.HTMLAttributes;
"kompas-paywall": LocalJSX.KompasPaywall & JSXBase.HTMLAttributes;
"kompas-paywall-banner-registration": LocalJSX.KompasPaywallBannerRegistration & JSXBase.HTMLAttributes;
"kompas-paywall-body": LocalJSX.KompasPaywallBody & JSXBase.HTMLAttributes;
diff --git a/src/components/kompas-metered-register/kompas-metered-register.tsx b/src/components/kompas-metered-register/kompas-metered-register.tsx
index b3f5a5a..d2896ce 100644
--- a/src/components/kompas-metered-register/kompas-metered-register.tsx
+++ b/src/components/kompas-metered-register/kompas-metered-register.tsx
@@ -1,4 +1,5 @@
-import { Component, Host, h } from '@stencil/core';
+import { Component, h, State, Prop, Fragment, Host } from '@stencil/core';
+import chevronUp from '../../../assets/fontawesome-free-5.15.3-web/svgs/solid/chevron-up.svg';
@Component({
tag: 'kompas-metered-register',
@@ -6,10 +7,105 @@ import { Component, Host, h } from '@stencil/core';
shadow: true,
})
export class KompasMeteredRegister {
+ /**
+ * state
+ */
+ /**
+ * state registerUrl untuk memberikan link kemana user akan dialihkan.
+ */
+ @State() registerUrl: string = 'https://account.kompas.cloud/register';
+ @State() isShowBanner: boolean = true;
+ @State() isExpandBanner: boolean = false;
+
+ /**
+ * prop countdownArticle untuk menghandle sudah berapa artikel gratis yang user baca.
+ */
+ @Prop() countdownArticle: number = 0;
+
+ /**
+ * mengelola tampilan pada section metered paywall
+ */
+ private bannerContent(): void {
+ if (!this.isExpandBanner) {
+ return (
+
+ Ini Adalah Artikel Gratis Terakhir Anda. Daftar Akun untuk Terus Membaca.
+
+ );
+ } else {
+ return (
+
+
+
+
+ Anda Sedang Membaca{' '}
+
+ Artikel Premium
+ Gratis Terakhir
+ {' '}
+ dari Kompas.id
+
+
+ Ayo daftar akun untuk akses ke beragam artikel dan fitur premium. Anda juga mendukung jurnalisme berkualitas dengan mendaftar akun.
+
+
+
+ Daftar Akun
+
+
+
+
+
+ {' '}
+
+
+
+
+ );
+ }
+ }
+
+ private bannerTemplate = (): void => {
+ return (
+
+ {this.bannerContent()}
+
+ );
+ };
+
+ private redirectToRegister = (): void => {
+ window.location.href = this.registerUrl;
+ };
+
+ private triggerExpandBanner = (): void => {
+ this.isExpandBanner = !this.isExpandBanner;
+ };
+
+ componentDidLoad() {
+ const getCountdown = this.countdownArticle;
+ if (!getCountdown) {
+ this.isShowBanner = false;
+ return;
+ }
+ }
+
render() {
return (
-
+ {this.isShowBanner ? (
+
+
+
+
{this.bannerTemplate()}
+
+
+
+
+ ) : null}
);
}
diff --git a/src/index.html b/src/index.html
index 0f26fdb..c21cf55 100644
--- a/src/index.html
+++ b/src/index.html
@@ -1,93 +1,119 @@
+
+
+
+ Babak Baru Polemik Istana Burung Garuda, Tiga Asosiasi Tolak Pengayaan Desain Karya Nyoman Nuarta
+
+
+
+
+
+
+
+
+
+
+
- #app {
- font-family: Avenir, Helvetica, Arial, sans-serif;
- -webkit-font-smoothing: antialiased;
- -moz-osx-font-smoothing: grayscale;
- text-align: center;
- color: #2c3e50;
- margin-top: 60px;
- }
-
-
-
-
-
-
-
-
-
-
-
Lipsum Dei
-
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Adipisci similique omnis dolorem dolores aliquam quis
- perspiciatis fugiat illum nisi laboriosam accusantium quam explicabo suscipit, asperiores blanditiis, ipsum
- exercitationem, reiciendis vitae!
-
-
-
-
-
+
+
+
-
-
-
Lorem ipsum dolor sit, amet consectetur adipisicing elit. Adipisci similique omnis dolorem dolores aliquam quis
- perspiciatis fugiat illum nisi laboriosam accusantium quam explicabo suscipit, asperiores blanditiis, ipsum
- exercitationem, reiciendis vitae!
-
-
-
+ Lorem ipsum dolor sit, amet consectetur adipisicing elit. Adipisci similique omnis dolorem dolores aliquam quis perspiciatis fugiat illum nisi laboriosam accusantium quam
+ explicabo suscipit, asperiores blanditiis, ipsum exercitationem, reiciendis vitae!
+
+
+
+
-
-
-
-
-
-
+ > -->
+
+
+
+
+
+
+