Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 68 additions & 47 deletions pos-module-push-notifications/app/assets/style/app.css
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
/*
styling for the push notifications demo app, mirroring the layout
conventions used in pos-module-user/app (pos-app shell, centered intro
page for logged-out visitors, a fixed-width page area with a top nav
for logged-in users)
styling for the push notifications demo app

page background and font
layout
intro page
logged in page
header
*/



/* page background and font
/* layout
============================================================================ */
.pos-app body {
min-height: 100vh;
padding: 0;
.app-page {
display: flex;
flex-direction: column;
flex-grow: 1;
}

background-color: var(--pos-color-page-background);
.app-container {
width: 100%;
max-width: 700px;
margin-block: auto;
margin-inline: auto;
}


Expand All @@ -36,10 +39,15 @@

.app-intro-content .pos-heading-2 {
margin-block-end: var(--pos-padding-page);
display: flex;
flex-direction: column;
align-items: center;
gap: var(--pos-gap-button-button);
}

.app-intro-nav {
display: flex;
position: relative;
justify-content: center;

font-weight: 500;
Expand All @@ -49,11 +57,55 @@
height: var(--pos-height-button);
padding-inline: calc(var(--pos-padding-button) * 2);
display: flex;
position: relative;
align-items: center;
justify-content: center;

transition-delay: 0s;
}

.app-intro-nav a:hover {
.app-intro-nav a:hover,
.app-intro-nav a:active {
color: var(--pos-color-highlight-text);

transition-delay: .1s;
}

.app-intro-nav li:hover,
.app-intro-nav li:has(a:focus-visible) {
anchor-name: --app-user-intro-nav-active;
}

.app-intro-nav:before {
width: 10px;
height: 10px;
position: absolute;
z-index: -1;

border-radius: var(--pos-radius-button);
background-color: transparent;

transition: all .2s ease-in-out;

content: '';
}

.app-intro-nav:has(li:hover):before,
.app-intro-nav:has(a:focus-visible):before {
background-color: var(--pos-color-highlight-background);
}

@supports (anchor-name: --app-user-intro-nav-active) {
.app-intro-nav:before {
width: anchor-size(width);
height: anchor-size(height);
position-anchor: --app-user-intro-nav-active;
inset-inline-start: anchor(start);
}
}

.app-intro-nav:has(a:active):before {
scale: .96;
}

.app-intro-footer {
Expand All @@ -66,18 +118,12 @@



/* logged in page
/* header
============================================================================ */
.app-page {
width: 640px;
max-width: 100%;
padding: var(--pos-padding-page);
margin-inline: auto;
}

.app-nav {
padding-block-end: var(--pos-padding-page);
margin-block-end: var(--pos-padding-page);
display: flex;
flex-wrap: wrap;
align-items: center;
gap: var(--pos-gap-button-button);
}
Expand All @@ -95,34 +141,9 @@
}

.app-nav-link {
height: var(--pos-height-button);
padding-inline: var(--pos-padding-button);
display: inline-flex;
align-items: center;

font-weight: 500;
}

.app-nav-link:hover {
color: var(--pos-color-highlight-text);
}

.app-page .pos-card + .pos-card {
margin-block-start: var(--pos-gap-section-section);
}



/* push notifications demo form
============================================================================ */
.pos-form-simple fieldset:has(label + .pos-form-multiselect) {
display: flex;
flex-direction: column;
gap: .2em;
}

.pos-form-simple fieldset:has(label + .pos-form-multiselect) label {
margin-inline-start: -.1ex;
margin-block-end: .1em;
align-self: start;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="stylesheet" href="{{ 'modules/user/style/pos-user-form.css' | asset_url }}">
<link rel="stylesheet" href="{{ 'style/app.css' | asset_url }}">
{% liquid
assign sw_path = '/sw.js'
assign sw_path = '/sw.js?a'
%}
{% render 'modules/push_notifications/init', service_worker_path: sw_path %}
</head>
Expand All @@ -17,11 +17,11 @@
<main class="app-page">
<nav class="app-nav">
<a href="/" class="app-nav-brand">Push Notifications Demo</a>
<a href="/settings" class="app-nav-link">Settings</a>
<div class="app-nav-user">
{% render 'modules/common-styling/user/avatar', size: 'xs', name: context.current_user.email, image_src: '' %}
<span class="pos-supplementary">{{ context.current_user.email }}</span>
</div>
<a href="/settings" class="app-nav-link">Settings</a>
<form method="post" action="/sessions" style="display:inline">
<input type="hidden" name="authenticity_token" value="{{ context.authenticity_token }}">
<input type="hidden" name="_method" value="delete">
Expand Down
80 changes: 42 additions & 38 deletions pos-module-push-notifications/app/views/pages/index.liquid
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
---
slug: /
method: get
layout: application
---
{% if context.current_user %}

{% liquid
function users = 'modules/user/queries/user/search',
id: null,
Expand All @@ -20,50 +16,58 @@ layout: application
assign default_recipients = []
assign default_recipients << context.current_user.id
%}
<section class="pos-card pos-card-highlighted">

<div class="app-container">
<h1 class="pos-heading-3">Send a notification</h1>
<form method="post" action="/push_notifications/demo" class="pos-form pos-form-simple">
<input type="hidden" name="authenticity_token" value="{{ context.authenticity_token }}">
<fieldset>
<label for="push-recipients">Send to</label>
{% render 'modules/common-styling/forms/multiselect',
id: 'push-recipients',
name: 'user_ids',
list: recipient_options,
selected: default_recipients,
view: null,
placeholder: null,
placeholder_filter: null,
placeholder_empty: null,
form: null,
showFilter: true,
combine_selected: true,
multiline: true,
required: false %}
</fieldset>
<fieldset>
<label for="push-title">Title</label>
<input type="text" id="push-title" name="title" value="Test Notification" class="pos-form-input">
</fieldset>
<fieldset>
<label for="push-body">Content</label>
<textarea id="push-body" name="body" class="pos-form-input">Hello from push_notifications demo!</textarea>
</fieldset>
<fieldset class="pos-form-actions">
<button type="submit" class="pos-button pos-button-primary">Send notification</button>
</fieldset>
</form>
</section>
<section class="pos-card pos-card-highlighted">
<form method="post" action="/push_notifications/demo" class="pos-form pos-form-simple">
<input type="hidden" name="authenticity_token" value="{{ context.authenticity_token }}">
<fieldset>
<label for="push-recipients">Send to</label>
{% render 'modules/common-styling/forms/multiselect',
id: 'push-recipients',
name: 'user_ids',
list: recipient_options,
selected: default_recipients,
view: null,
placeholder: null,
placeholder_filter: null,
placeholder_empty: null,
form: null,
showFilter: true,
combine_selected: true,
multiline: true,
required: false %}
</fieldset>
<fieldset>
<label for="push-title">Title</label>
<input type="text" id="push-title" name="title" value="Test Notification" class="pos-form-input">
</fieldset>
<fieldset>
<label for="push-body">Content</label>
<textarea id="push-body" name="body" class="pos-form-input">Hello from push_notifications demo!</textarea>
</fieldset>
<fieldset class="pos-form-actions">
<button type="submit" class="pos-button pos-button-primary">Send notification</button>
</fieldset>
</form>
</section>
</div>

{% else %}

<section class="app-intro-content">
<h2 class="pos-heading-2">Push Notifications Demo</h2>
<nav>
<ul class="app-intro-nav">
<li><a href="/sessions/new">Log in</a></li>
<li><a href="/users/new">Register</a></li>
</ul>
</nav>
</section>

<footer class="app-intro-footer">
Powered by <a href="https://platformos.com">platformOS</a>
</footer>

{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ slug: push_notifications/demo
method: post
layout: application
---

{% liquid
if context.current_user == blank
redirect_to '/sessions/new'
Expand All @@ -26,12 +27,15 @@ layout: application

assign queued = result.queued
%}
<section class="pos-card">
<h1 class="pos-heading-3">Test Notification Result</h1>
<dl>
<dt>Recipients</dt><dd>{{ user_ids | size }}</dd>
<dt>Queued</dt><dd>{{ queued }}</dd>
</dl>
<p>Delivery happens asynchronously — check instance logs or the <code>push_notification_sent</code>/<code>push_notification_failed</code>/<code>push_subscription_expired</code> events for actual outcomes.</p>
<a href="/">Back</a>
</section>

<div class="app-container">
<section class="pos-card">
<h1 class="pos-heading-3">Test Notification Result</h1>
<dl>
<dt>Recipients</dt><dd>{{ user_ids | size }}</dd>
<dt>Queued</dt><dd>{{ queued }}</dd>
</dl>
<p>Delivery happens asynchronously — check instance logs or the <code>push_notification_sent</code>/<code>push_notification_failed</code>/<code>push_subscription_expired</code> events for actual outcomes.</p>
<a href="/">Back</a>
</section>
</div>
22 changes: 11 additions & 11 deletions pos-module-push-notifications/app/views/pages/settings.liquid
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
---
slug: settings
method: get
layout: application
---
{% liquid
if context.current_user == blank
redirect_to '/sessions/new'
Expand All @@ -15,12 +10,17 @@ layout: application
limit: 100,
page: 1
%}
<section class="pos-card pos-card-highlighted">

<div class="app-container">

<h1 class="pos-heading-3">Push notifications</h1>
{% render 'modules/push_notifications/register' %}
</section>
<section class="pos-card pos-card-highlighted">
{% render 'modules/push_notifications/register' %}
</section>

<section class="pos-card">
<h2 class="pos-heading-3">Your subscriptions</h2>
{% render 'modules/push_notifications/subscriptions/index', subscriptions: subs.results %}
</section>
<section class="pos-card">
{% render 'modules/push_notifications/subscriptions/index', subscriptions: subs.results %}
</section>

</div>
Loading
Loading