Skip to content

Commit 283ccbc

Browse files
authored
Merge pull request #547 from 47degrees/feature/search-pattern-theme
Enable Search for Pattern Theme
2 parents c2c2a71 + e79283c commit 283ccbc

File tree

9 files changed

+84
-47
lines changed

9 files changed

+84
-47
lines changed

src/main/resources/_sass/light-style/_doc-search.scss renamed to src/main/resources/_sass/_doc-search.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
div[id$='search-dropdown'] {
1+
#search-dropdown {
22
position: relative;
33

44
.dropdown {
@@ -9,6 +9,7 @@ div[id$='search-dropdown'] {
99

1010
label {
1111
padding-right: 0.3em;
12+
font-weight: normal;
1213

1314
i {
1415
padding-right: 0.2em;
@@ -32,6 +33,7 @@ div[id$='search-dropdown'] {
3233

3334
.dropdown-item {
3435
width: 100%;
36+
text-align: left;
3537

3638
.dropdown-item-link {
3739
padding: 12px 9px;

src/main/resources/_sass/_docs.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
span {
5050
margin-left: 10px;
5151
font-size: 14px;
52-
text-transform: uppercase;
5352
}
5453
}
5554
}
@@ -107,6 +106,10 @@
107106
opacity: 1;
108107
}
109108
}
109+
110+
.to-uppercase {
111+
text-transform: uppercase;
112+
}
110113
}
111114

112115
#wrapper.toggled #page-content-wrapper {

src/main/resources/_sass/_home.scss

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,20 @@
5252
.fa-file-text {
5353
font-size: 17px;
5454
}
55-
&:hover,
56-
&:focus,
57-
&.focus {
58-
opacity: 0.5;
59-
text-decoration: none;
55+
}
56+
57+
label {
58+
color: #fff;
59+
font-size: 15px;
60+
font-weight: 400;
61+
margin-right: 6px;
62+
63+
i {
64+
margin-right: 6px;
6065
}
6166
}
6267

63-
&:first-child {
68+
&:not(:last-child) {
6469
margin-right: 50px;
6570

6671
@media screen and (max-width: $screen-xs-max) {
@@ -73,6 +78,15 @@
7378
}
7479
}
7580

81+
a.transparent-on-hover {
82+
&:hover,
83+
&:focus,
84+
&.focus {
85+
opacity: 0.5;
86+
text-decoration: none;
87+
}
88+
}
89+
7690
.horizontal-nav {
7791
border:1px solid #ccc;
7892
border-width:1px 0;

src/main/resources/css/light-style.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@import "light-style/button";
1313
@import "light-style/masthead";
1414
@import "light-style/main";
15-
@import "light-style/doc-search";
15+
@import "doc-search";
1616
@import "light-style/doc-versions";
1717
@import "light-style/footer";
1818
@import "light-style/light-docs";

src/main/resources/css/pattern-style.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
@import "bootstrap";
99
@import "bootstrap_override";
1010
@import "docs";
11+
@import "doc-search";
1112
@import "home";
1213
@import "colors";

src/main/resources/js/main.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ function shareSiteTwitter(text) {
5353
return false;
5454
}
5555

56-
function shareSiteGoogle() {
57-
launchPopup('https://plus.google.com/share?url='+baseURL);
58-
return false;
59-
}
60-
6156
function launchPopup(url) {
6257
window.open(url, 'Social Share', 'height=320, width=640, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no');
6358
}

src/main/scala/microsites/layouts/DocsLayout.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,14 @@ class DocsLayout(config: MicrositeSettings) extends Layout(config) {
3636
val text = s"${config.identity.name} ${config.identity.description}"
3737

3838
def siteSearch: Seq[TypedTag[String]] = {
39+
val classes =
40+
if (config.visualSettings.theme == "pattern") "search-nav hidden-xs hidden-sm"
41+
else "search-nav"
42+
3943
if (config.searchSettings.searchEnabled) {
4044
Seq(
4145
li(
42-
cls := "search-nav",
46+
cls := classes,
4347
div(
4448
id := "search-dropdown",
4549
label(
@@ -69,7 +73,7 @@ class DocsLayout(config: MicrositeSettings) extends Layout(config) {
6973
Seq(
7074
li(
7175
id := "gh-eyes-item",
72-
cls := "hidden-xs",
76+
cls := "hidden-xs to-uppercase",
7377
a(
7478
href := config.gitSiteUrl,
7579
target := "_blank",
@@ -80,7 +84,7 @@ class DocsLayout(config: MicrositeSettings) extends Layout(config) {
8084
),
8185
li(
8286
id := "gh-stars-item",
83-
cls := "hidden-xs",
87+
cls := "hidden-xs to-uppercase",
8488
a(
8589
href := config.gitSiteUrl,
8690
target := "_blank",
@@ -100,15 +104,14 @@ class DocsLayout(config: MicrositeSettings) extends Layout(config) {
100104
li(a(href := "#", onclick := s"shareSiteTwitter('$text');", i(cls := "fa fa-twitter"))),
101105
li(
102106
a(href := "#", onclick := s"shareSiteFacebook('$text');", i(cls := "fa fa-facebook"))
103-
),
104-
li(a(href := "#", onclick := "shareSiteGoogle();", i(cls := "fa fa-google-plus")))
107+
)
105108
)
106109
} else Seq.empty
107110
} else Seq.empty
108111
}
109112

110113
val maybeSearch =
111-
if (config.visualSettings.theme != "pattern" && config.searchSettings.searchEnabled) {
114+
if (config.searchSettings.searchEnabled) {
112115
Seq(siteSearch)
113116
} else Seq.empty
114117

@@ -307,7 +310,10 @@ class DocsLayout(config: MicrositeSettings) extends Layout(config) {
307310
if (config.visualSettings.theme == "pattern") scriptsDocsPattern else scriptsDocsLight
308311

309312
def scriptsDocsPattern: List[TypedTag[String]] =
310-
scripts ++ List(script(src := "{{ site.baseurl }}/js/main.js"))
313+
scripts ++ List(
314+
searchScript,
315+
script(src := "{{ site.baseurl }}/js/main.js")
316+
)
311317

312318
def scriptsDocsLight: List[TypedTag[String]] =
313319
scripts ++ List(

src/main/scala/microsites/layouts/HomeLayout.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ class HomeLayout(config: MicrositeSettings) extends Layout(config) {
5252
div(
5353
cls := "row",
5454
div(
55-
cls := "col-xs-6",
55+
cls := "col-xs-3",
5656
a(
5757
href := "{{ site.baseurl }}/",
5858
cls := "brand",
5959
div(cls := "icon-wrapper", span(config.identity.name))
6060
)
6161
),
62-
div(cls := "col-xs-6", buildCollapseMenu)
62+
div(cls := "col-xs-9", buildCollapseMenu)
6363
)
6464
)
6565
),

src/main/scala/microsites/layouts/Layout.scala

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -411,26 +411,63 @@ abstract class Layout(config: MicrositeSettings) {
411411
)
412412
}
413413

414+
def searchBar: Option[TypedTag[String]] = {
415+
val classes =
416+
if (config.visualSettings.theme == "pattern") "search-nav hidden-xs"
417+
else "search-nav"
418+
419+
if (config.searchSettings.searchEnabled) {
420+
Some(
421+
li(
422+
cls := classes,
423+
div(
424+
id := "search-dropdown",
425+
label(
426+
i(cls := "fa fa-search"),
427+
"Search"
428+
),
429+
input(
430+
id := "search-bar",
431+
`type` := "text",
432+
placeholder := "Enter keywords here...",
433+
onclick := "displayToggleSearch(event)"
434+
),
435+
ul(
436+
id := "search-dropdown-content",
437+
cls := "dropdown dropdown-content"
438+
)
439+
)
440+
)
441+
)
442+
} else Option.empty
443+
}
444+
414445
def buildCollapseMenu: TypedTag[String] =
415446
nav(
416447
cls := "text-right",
417448
ul(
418449
cls := "",
450+
searchBar,
419451
li(
420452
a(
453+
cls := "transparent-on-hover",
421454
href := config.gitSiteUrl,
422455
i(cls := s"fa ${config.gitHostingIconClass}"),
423456
target := "_blank",
424457
rel := "noopener noreferrer",
425-
span(cls := "hidden-xs", config.gitSettings.gitHostingService.name)
458+
span(cls := "hidden-sm hidden-xs", config.gitSettings.gitHostingService.name)
426459
)
427460
),
428461
if (!config.urlSettings.micrositeDocumentationUrl.isEmpty)
429462
li(
430463
a(
464+
cls := "transparent-on-hover",
431465
href := s"${config.urlSettings.micrositeDocumentationUrl}",
432466
i(cls := "fa fa-file-text"),
433-
span(cls := "hidden-xs", config.urlSettings.micrositeDocumentationLabelDescription)
467+
span(
468+
cls := "hidden-sm hidden-xs",
469+
config.urlSettings.micrositeDocumentationLabelDescription
470+
)
434471
)
435472
)
436473
else ()
@@ -439,28 +476,7 @@ abstract class Layout(config: MicrositeSettings) {
439476

440477
def buildLightCollapseMenu: TypedTag[String] =
441478
ul(
442-
"{% if site.search_enabled %}",
443-
li(
444-
cls := "search-nav",
445-
div(
446-
id := "search-dropdown",
447-
label(
448-
i(cls := "fa fa-search"),
449-
"Search"
450-
),
451-
input(
452-
id := "search-bar",
453-
`type` := "text",
454-
placeholder := "Enter keywords here...",
455-
onclick := "displayToggleSearch(event)"
456-
),
457-
ul(
458-
id := "search-dropdown-content",
459-
cls := "dropdown dropdown-content"
460-
)
461-
)
462-
),
463-
"{% endif %}",
479+
searchBar,
464480
"{% if site.data.versions %}",
465481
raw("""{% assign own_version = site.data.versions | where: "own", true | first %}"""),
466482
li(

0 commit comments

Comments
 (0)