Skip to content

Commit e6a87fd

Browse files
authored
Add labels and styling to cards, allow mixed card type in a section (#248)
1 parent 030908b commit e6a87fd

File tree

7 files changed

+116
-9
lines changed

7 files changed

+116
-9
lines changed

preview-src/docs-ndl.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
[.cards.icon-l]
1010
== CTA cards
1111

12+
13+
[.featured.label--featured]
1214
=== Deployment options
1315

1416
[.icon]

preview-src/docs-sub-hub.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ endif::[]
2323

2424
This section is designed to help you learn how to import various types of data into Neo4j. From JSON to APIs to another database, you can retrieve data from nearly any source and use it to populate your graph.
2525

26+
27+
[role=label--new-5.12]
2628
=== `LOAD CSV`
2729
[.icon]
2830
image:icons/ndl/icon-import.svg[]
@@ -34,6 +36,7 @@ Use Cypher for importing bulk data into Neo4j. Suited for non-admin users.
3436
link:{docs-home}/cypher-manual/current/clauses/load-csv/[]
3537

3638

39+
[.labs.label--labs]
3740
=== From relational into graph
3841

3942
[.icon]
@@ -46,6 +49,7 @@ Learn how to translate and migrate tabular data and relational datasets into a g
4649
link:{docs-home}/data-import/relational-to-graph-import/[]
4750

4851

52+
[.not-selectable]
4953
=== Neo4j Connectors
5054

5155
[.icon]
@@ -57,7 +61,9 @@ Learn how to use connectors to connect data from various sources into Neo4j.
5761
[.link]
5862
link:{docs-home}/connectors/[]
5963

60-
=== Neo4j Data Importer
64+
65+
[.label--graph-academy.label--featured]
66+
=== Graph Academy
6167

6268
[.icon]
6369
image:icons/ndl/icon-neo4j.svg[]
@@ -94,6 +100,8 @@ link:{docs-home}/apoc/current/import/[*Import data using APOC Core*]
94100
[.cards.selectable]
95101
== Keep exploring
96102

103+
104+
[.graph-academy.label--graph-academy.label--featured]
97105
=== GraphAcademy
98106

99107
[.icon]

src/css/docs-ndl.css

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,20 +373,21 @@ body.docs-ndl .paragraph.footer-link {
373373

374374
/* selectable cards */
375375

376-
body.docs-ndl .cards.selectable .sect2 {
376+
body.docs-ndl .cards .sect2.selectable {
377377
cursor: pointer;
378378
}
379379

380-
body.docs-ndl .cards.selectable .sect2 a {
380+
body.docs-ndl .cards .sect2.selectable a {
381381
text-decoration: none;
382382
}
383383

384-
body.docs-ndl .cards.selectable .sect2:hover {
385-
transform: translateY(-0.25rem);
386-
transition: 0.2s linear;
384+
body.docs-ndl .cards .sect2.selectable a:hover {
385+
transform: scale(1.02);
386+
transition: 0.1s linear;
387+
box-shadow: 0 4px 8px 0 rgba(12, 26, 37, 0.08);
387388
}
388389

389-
body.docs-ndl .cards.selectable .sect2:hover div.description {
390+
body.docs-ndl .cards .sect2.selectable:hover div.description {
390391
text-decoration: underline;
391392
}
392393

@@ -474,6 +475,7 @@ body.docs-ndl.explainer .sectionbody > div.sect2 {
474475
}
475476

476477
body.docs-ndl .cards .sect2 > a,
478+
body.docs-ndl .cards .sect2.not-selectable,
477479
body.docs-ndl .cards:not(.selectable) .sect2,
478480
body.docs-ndl .lists .sect2 {
479481
overflow: hidden;
@@ -490,7 +492,40 @@ body.docs-ndl .lists .sect2 {
490492
background: var(--color-white);
491493
}
492494

495+
/* styles for specific types of cards:
496+
- featured - for new and exciting items
497+
- labs
498+
- graph-academy
499+
*/
500+
501+
/* this would give a background image on cards marked with [.ga-promo] */
502+
body.docs-ndl .cards .sectionbody > div.sect2.graph-academy > a,
503+
body.docs-ndl .cards .sectionbody > div.sect2.graph-academy:not(.selectable) {
504+
background: #fff url(../img/ad-blob.svg) no-repeat 100% 100%;
505+
border: 1px solid var(--success-color);
506+
box-shadow: 0 2px 4px 0 rgba(63, 120, 36, 0.5), 0 1px 2px 0 rgba(63, 120, 36, 0.2);
507+
}
508+
509+
body.docs-ndl .cards .sectionbody > div.sect2.labs > a,
510+
body.docs-ndl .cards .sectionbody > div.sect2.labs:not(.selectable) {
511+
border: 1px solid var(--color-labs);
512+
box-shadow: 0 2px 4px 0 rgba(90, 52, 170, 0.5), 0 1px 2px 0 rgba(90, 52, 170, 0.2);
513+
}
514+
515+
body.docs-ndl .cards .sectionbody > div.sect2.featured > a,
516+
body.docs-ndl .cards .sectionbody > div.sect2.featured:not(.selectable) {
517+
border: 1px solid var(--success-color);
518+
box-shadow: 0 2px 4px 0 rgba(63, 120, 36, 0.5), 0 1px 2px 0 rgba(63, 120, 36, 0.2);
519+
}
520+
521+
/* add a labs label to a title in a card */
522+
body.docs-ndl .header-label-container > div.labels {
523+
display: inline-flex;
524+
margin-left: auto;
525+
}
526+
493527
body.docs-ndl .cards .sect2 > a,
528+
body.docs-ndl .cards .sect2.not-selectable,
494529
body.docs-ndl .cards:not(.selectable) .sect2,
495530
body.docs-ndl .widget:not(.video) {
496531
/* box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.06); */
@@ -539,6 +574,20 @@ body.docs-ndl .widget .icon {
539574
order: 1;
540575
padding: 0;
541576
margin: 0;
577+
width: 100%;
578+
}
579+
580+
body.docs-ndl .cards .sect2 .icon p {
581+
display: flex;
582+
width: -webkit-fill-available;
583+
justify-content: space-between;
584+
}
585+
586+
body.docs-ndl .cards .sect2 .icon p div.labels {
587+
display: flex;
588+
flex-direction: row;
589+
gap: 0.25rem;
590+
height: min-content;
542591
}
543592

544593
body.docs-ndl .cards .icon span {
@@ -578,6 +627,7 @@ body.docs-ndl .lists .sect2 h3 {
578627
order: 2;
579628
margin: 0;
580629
font-weight: var(--font-weight-semibold);
630+
width: -webkit-fill-available;
581631
}
582632

583633
body.docs-ndl .cards .sect2 h3 .anchor::before {
@@ -601,7 +651,7 @@ body.docs-ndl .cards .sect2 .paragraph:not(.icon) {
601651
/* flex-grow: 1; */
602652
}
603653

604-
body.docs-ndl .cards.selectable .sect2 .paragraph.link {
654+
body.docs-ndl .cards .sect2.selectable .paragraph.link {
605655
display: none;
606656
}
607657

src/css/labels.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ span.label--recommended {
158158
span.label--added,
159159
span.label--changed,
160160
span.label--new,
161+
span.label--featured,
161162
span.label--renamed,
162163
span.label--updated,
163164
span.label--yes {
@@ -224,3 +225,11 @@ span.label--cluster-member-single {
224225
background: rgba(var(--colors-lemon-10));
225226
background: rgba(var(--colors-lemon-60));
226227
}
228+
229+
span.label--labs {
230+
background: var(--color-labs);
231+
}
232+
233+
span.label--graph-academy {
234+
background: var(--success-color);
235+
}

src/css/vars.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@
239239
NB: admonitions are dark text on light background
240240
to use the same colors on labels, reverse the
241241
background and color */
242+
--featured-color: rgba(var(--colors-hibiscus-70));
243+
--featured-border-color: rgba(var(--colors-lavender-50));
244+
--featured-background-color: rgba(var(--colors-hibiscus-10));
242245
--caution-color: rgba(var(--colors-marigold-70));
243246
--caution-border-color: rgba(var(--colors-marigold-50));
244247
--caution-background-color: rgba(var(--colors-marigold-10));

src/js/70-docs-ndl.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ document.addEventListener('DOMContentLoaded', function () {
88
}
99

1010
var makeClickable = function (card) {
11-
var links = card.querySelectorAll('div.link')
11+
var links = card.querySelectorAll('div.sect2:not(.not-selectable) div.link')
1212
links.forEach(function (link) {
1313
var target = link.querySelector('a').getAttribute('href')
1414
var card = link.parentElement
15+
card.classList.add('selectable')
1516
const cardLink = createElement('a', 'link')
1617
cardLink.setAttribute('href', target)
1718
moveElements(card, cardLink)
@@ -23,6 +24,18 @@ document.addEventListener('DOMContentLoaded', function () {
2324
})
2425
}
2526

27+
var moveLabels = function (section) {
28+
var cards = section.querySelectorAll('div.sect2')
29+
cards.forEach(function (card) {
30+
// do we have any labels to move?
31+
var labels = card.querySelector('div.labels')
32+
if (labels) {
33+
var icon = card.querySelector('div.icon p')
34+
icon.append(labels)
35+
}
36+
})
37+
}
38+
2639
// Remove <a> anchor tags from h3 elements on selectable cards in docs-ndl pages
2740
// the card is already wrapped in an anchor tag so we don't need an anchor inside the h3
2841
// and it introduces an unwanted ::after pseudo-element
@@ -33,4 +46,9 @@ document.addEventListener('DOMContentLoaded', function () {
3346
// Add links to cards
3447
document.querySelectorAll('.cards.selectable')
3548
.forEach(makeClickable)
49+
50+
// Move labels to the icon div to position them
51+
// in the top-right corner of the card
52+
document.querySelectorAll('.cards')
53+
.forEach(moveLabels)
3654
})

src/js/data/rolesData.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
{
2+
"featured": {
3+
"description": "Featured cards",
4+
"labelCategory": "content",
5+
"displayText": "NEW"
6+
},
7+
"labs":{
8+
"description": "Neo4j Labs project",
9+
"labelCategory": "content",
10+
"product": "Labs",
11+
"displayText": "Labs"
12+
},
13+
"graph-academy":{
14+
"description": "Neo4j Graph Academy",
15+
"labelCategory": "content",
16+
"product": "Graph Academy",
17+
"displayText": "Graph Academy"
18+
},
219
"enterprise":{
320
"description": "Function available in Enterprise Edition only",
421
"labelCategory": "product",

0 commit comments

Comments
 (0)