Skip to content
Draft
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
6 changes: 6 additions & 0 deletions assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,12 @@ button.prpl-info-icon {
}
}

/* While the tour points at a popover, keep it at the top so the tour box fits below. */
.prpl-popover.prpl-popover-in-tour {
margin-top: var(--prpl-padding);
max-height: calc(100vh - 280px);
}

.driver-popover.prpl-driverjs-theme {
background-color: var(--prpl-background-monthly);
color: var(--prpl-color-text);
Expand Down
142 changes: 137 additions & 5 deletions assets/css/page-widgets/monthly-badges.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,122 @@
Popover styles.
\*------------------------------------*/
#prpl-popover-monthly-badges {
padding: var(--prpl-gap);

.prpl-widgets-container {
.prpl-monthly-badges-popover {
container-type: inline-size;
}

/* Number cards: the totals at the top and the per-year cards. */
.prpl-badges-stat {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 0.25rem;
padding: var(--prpl-padding);
border-radius: var(--prpl-border-radius-big);
background: var(--prpl-background-monthly);
text-align: center;
}

.prpl-badges-stat-number {
font-size: var(--prpl-font-size-3xl);
font-weight: 600;
line-height: 1;
color: var(--prpl-color-text);
}

.prpl-badges-stat-label {
font-size: var(--prpl-font-size-base);
}

/* Top row: intro text and the two totals. */
.prpl-badges-summary {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: var(--prpl-padding);
padding-bottom: var(--prpl-gap);
border-bottom: 1px solid var(--prpl-color-divider);

.prpl-badges-stat,
.prpl-badges-summary-intro {
background: var(--prpl-background-content);
}
}

.prpl-badges-summary-intro {
padding: var(--prpl-padding);
border-radius: var(--prpl-border-radius-big);

p {
margin: 0;

& + p {
margin-top: 0.5rem;
}
}

strong {
color: var(--prpl-color-text);
}
}

/* One section per year. */
.prpl-badges-year {
padding: var(--prpl-padding) 0 var(--prpl-gap);
border-bottom: 1px solid var(--prpl-color-divider);
}

.prpl-badges-year-title {
margin: 0 0 var(--prpl-padding);
font-size: var(--prpl-font-size-xl);
color: var(--prpl-color-headings);
}

.prpl-badges-year-content {
display: grid;
grid-template-columns: 2fr 1fr;
gap: var(--prpl-padding);
align-items: start;
}

.prpl-badges-year-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: var(--prpl-padding);

/* The badge's own 6px margin is the only space above the name. */
.prpl-badge {
gap: 0;
}
}

.prpl-badges-year-stats {
display: grid;
gap: var(--prpl-padding);
}

/* The wrapper is not a grid item, so the badge needs to be a block to size it. */
.prpl-badge-image prpl-badge {
display: block;
margin-bottom: 6px; /* Design: 6px between badge and name; no spacing variable gives 6px. */
}

.prpl-badge-name {
margin: 0;
font-size: var(--prpl-font-size-small);
text-align: center;
line-height: 1.2;
}

/* The content and streak badges (until they get their own popovers). */
.prpl-widgets-container.in-popover {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(var(--prpl-column-min-width), 1fr));
grid-gap: var(--prpl-gap);
grid-auto-rows: auto;
margin-top: var(--prpl-gap);
}

.prpl-widget-title {
Expand All @@ -78,10 +188,6 @@
background: var(--prpl-background-monthly);
}

.badge-group-monthly {
background-color: transparent;
}

.prpl-widget-wrapper-content {

.prpl-widget-title {
Expand All @@ -103,6 +209,32 @@
background-color: transparent;
}
}

@container (max-width: 900px) {

.prpl-badges-summary {
grid-template-columns: 1fr 1fr;
}

.prpl-badges-summary-intro {
grid-column: 1 / -1;
}

.prpl-badges-year-content {
grid-template-columns: 1fr;
}

.prpl-badges-year-stats {
grid-template-columns: 1fr 1fr;
}
}

@container (max-width: 520px) {

.prpl-badges-year-grid {
grid-template-columns: repeat(2, 1fr);
}
}
}

/* This is the badge streak widget. */
Expand Down
132 changes: 131 additions & 1 deletion assets/css/web-components/prpl-badge.css
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ prpl-badge {
width: 20px;
height: 20px;
background-color: var(--prpl-color-icon-missed-badge);
border: 2px solid #fff;
border: 2px solid var(--prpl-background-paper);
border-radius: 50%;
position: absolute;
top: 10%;
Expand All @@ -87,3 +87,133 @@ prpl-badge {
}
}
}

/*------------------------------------*\
Monthly badges popover: hover states.

A missed badge (still earnable) shows how many points are left;
the current month's badge shows "In progress" with a small wobble.
\*------------------------------------*/
.prpl-badge[data-state] {
position: relative;
cursor: default;
border-radius: var(--prpl-radius-paper);

/* Reveal on :focus too, so a tap on a touch screen shows the details;
the outline is only for keyboard focus. */
&:focus {
outline: none;
}

&:focus-visible {
outline: 2px solid var(--prpl-color-link);
outline-offset: 4px;
}

.prpl-badge-image {
position: relative;
display: block;
}

&:is(:hover, :focus) prpl-badge[complete="false"] img {
opacity: 1;
filter: none;
}
}

.prpl-badge-points-to-go {
position: absolute;
top: 0;
left: 50%;
z-index: 1;
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 2px 0.5rem 2px 2px;
border-radius: 999px;
background: var(--prpl-background-alert-error);
color: var(--prpl-color-text);
font-size: var(--prpl-font-size-small);
line-height: 1.2;
white-space: nowrap;
pointer-events: none;
opacity: 0;
transform: translate(-50%, 4px);
transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.prpl-badge-points-to-go-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--prpl-color-icon-missed-badge);
color: #fff;
font-weight: 600;
}

.prpl-badge[data-state="missed"]:is(:hover, :focus) {

.prpl-badge-points-to-go {
opacity: 1;
transform: translate(-50%, 0);
}

/* The pill carries the "!" now. */
prpl-badge::after {
opacity: 0;
}
}

.prpl-badge-name-hover {
display: none;
font-weight: 600;
}

.prpl-badge[data-state="in-progress"]:is(:hover, :focus) {

.prpl-badge-name-default {
display: none;
}

.prpl-badge-name-hover {
display: inline;
}

prpl-badge img {
animation: prpl-badge-wobble 0.8s ease-in-out;
}
}

@keyframes prpl-badge-wobble {

0%,
100% {
transform: rotate(0);
}

20% {
transform: rotate(-8deg);
}

40% {
transform: rotate(6deg);
}

60% {
transform: rotate(-4deg);
}

80% {
transform: rotate(2deg);
}
}

@media (prefers-reduced-motion: reduce) {

.prpl-badge[data-state="in-progress"]:is(:hover, :focus) prpl-badge img {
animation: none;
}
}
4 changes: 4 additions & 0 deletions assets/js/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ const prplDriverObj = prplDriver( {
} );

function prplTourShowPopover( popover ) {
// The popover sits above the tour box (top layer); this class keeps it at
// the top of the screen and leaves room for the tour box below it.
popover.classList.add( 'prpl-popover-in-tour' );
popover.showPopover();
prplMakePopoverBackdropTransparent( popover );
}

function prplTourHidePopover( popover ) {
popover.classList.remove( 'prpl-popover-in-tour' );
popover.hidePopover();
document.getElementById( popover.id + '-backdrop-transparency' ).remove();
}
Expand Down
Loading
Loading