UX improvements per Paul design

This commit is contained in:
Aaron Carlino 2019-11-25 15:55:32 +13:00
parent 5ae0ac4387
commit f39bfe12df
5 changed files with 103 additions and 34 deletions

View File

@ -2,11 +2,13 @@ require("prismjs/themes/prism-okaidia.css");
require("./src/theme/assets/scss/theme.scss");
require('./src/theme/assets/fontawesome/css/all.css');
require('./src/theme/assets/search/algolia.css');
const React = require('react');
const Layout = require('./src/components/Layout').default;
const NodeProvider = require('./src/components/NodeProvider').default;
const smoothScroll = require('smooth-scroll');
if (typeof window !== "undefined") {
smoothScroll('a[href*="#"]')
}

View File

@ -24,10 +24,13 @@ module.exports = {
<<<<<<< HEAD
name: `4`,
remote: `https://github.com/silverstripe/silverstripe-framework.git`,
<<<<<<< HEAD
=======
name: `docs--4`,
remote: `/Users/acarlino/Sites/gatsby-docs-4`,
>>>>>>> Docs/userguide switching
=======
>>>>>>> UX improvements per Paul design
branch: `4`,
patterns: `docs/en/**`
}

View File

@ -38,10 +38,11 @@ const Header: StatelessComponent<HeaderProps> = ({ handleSidebarToggle }): React
<div className="container position-relative py-2 d-flex">
<div className="docs-logo-wrapper">
<div className="site-logo">
<Link className="navbar-brand" to={ home ? home.slug : '/'} title="Go to the home page">
<img src={logo} alt="Silverstripe CMS documentation" />
<span>Documentation</span>
<Link style={{ backgroundImage: `url(${logo})`}} className="navbar-brand" to={ home ? home.slug : '/'} title="Go to the home page">
Silverstripe CMS Documentation
</Link>
<span />
<span>Documentation</span>
</div>
</div>
@ -52,7 +53,7 @@ const Header: StatelessComponent<HeaderProps> = ({ handleSidebarToggle }): React
<SearchBox identifier="header-search" />
</form>
</div>
<ul className="social-list list-inline d-flex flex-grow-1 flex-lg-grow-0 justify-content-between justify-content-lg-around align-items-center">
<ul className="social-list list-inline d-flex flex-grow-1 flex-lg-grow-0 align-items-center">
<li className="list-inline-item version-select">
<label htmlFor="version-select">Version: </label>
<select id="version-select" value={getCurrentVersion() || '4'} onChange={handleNavigate}>

View File

@ -1,5 +1,5 @@
import React from 'react'
import { StatelessComponent, ReactElement, useEffect } from 'react';
import { StatelessComponent, ReactElement, useEffect, useState } from 'react';
import { navigateTo } from "gatsby-link"
import useHierarchy from '../hooks/useHierarchy';
@ -18,6 +18,7 @@ const autocompleteSelected = (e) => {
const SearchBox: StatelessComponent<SearchBoxProps> = ({ identifier }): ReactElement|null => {
const { getCurrentVersion } = useHierarchy();
const [ isFocused, setFocus ] = useState(false);
useEffect(() => {
if (typeof window === 'undefined') return;
if (!process.env.GATSBY_DOCSEARCH_API_KEY) {
@ -46,13 +47,20 @@ const SearchBox: StatelessComponent<SearchBoxProps> = ({ identifier }): ReactEle
}, []);
const handleFocus = () => setFocus(true);
const handleBlur = () => setFocus(false);
return (
<>
<label className={ isFocused ? `hide` : `show` } htmlFor={identifier}>Search...</label>
<input
id={identifier}
type="search"
placeholder="Search the docs..."
className="form-control search-input"
onFocus={handleFocus}
onBlur={handleBlur}
/>
</>
)
};

View File

@ -14,11 +14,30 @@ body {
.search-form {
width: 75%;
margin: 0 auto;
position: relative;
label {
position: absolute;
left: 0;
top: calc(50% - 0.5rem);
font-size: 1rem;
z-index: 100;
transition: all 0.3s;
cursor: text;
&.hide {
transform: translateY(-15px);
opacity: 0;
}
}
.search-input {
border-radius: 5px;
background: $gray-200;
border: 1px solid $gray-900;
border-width: 0 0 1px 0;
border-radius: 0;
padding: 1rem 0;
&:focus {
color: $gray-900;
border-color: $gray-900;
box-shadow: none;
}
}
}
@ -82,26 +101,37 @@ code {
display: flex;
justify-content: flex-start;
align-items: center;
padding: 0 1rem;
.site-logo {
display: flex;
align-items: center;
justify-content: space-between;
width: 215px;
padding-left: 1rem;
.navbar-brand {
font-size: 1rem;
background-size: cover;
background-repeat: no-repeat;
width: 32px;
height: 32px;
text-indent: -9999em;
display: inline-block;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
span {
text-transform: uppercase;
font-size: 0.8rem;
color: $gray-850;
}
span {
&:nth-child(2) {
width: 1px;
background: $gray-700;
height: 32px;
}
&:nth-child(3) {
font-size: 1.25rem;
color: darken($gray-850, 5%);
font-weight: bold;
justify-self: flex-end;
}
}
img {
width: 7rem;
height: 1.5rem;
}
}
}
.docs-top-utilities {
@ -110,9 +140,12 @@ code {
margin: 0;
width: 25%;
li {
margin: 0;
margin: 0 1rem;
width: auto;
height: auto;
a {
color: $gray-850;
}
}
.version-select {
display: flex;
@ -123,21 +156,29 @@ code {
line-height: 1;
color: $gray-800;
label {
font-size: 0.7rem;
font-size: 0.75rem;
margin: 0 0.5rem;
color: $gray-900;
color: $gray-800;
text-transform: uppercase;
}
select {
appearance: none;
border: 0;
color: $gray-800;
background: none;
background: $theme-color-primary;
border-radius: 100px;
color: #fff;
padding: 0.25rem 1rem 0.25rem 0.5rem;
width: 62px;
padding-right: 2rem;
flex-shrink: 0;
flex-shrink: 0;
font-size: 1rem;
}
i {
pointer-events: none;
margin-left: -1rem;
margin: 5px 0 0 -1.25rem;
color: #fff;
font-size: 0.8rem;
}
}
}
@ -211,14 +252,23 @@ h1, h2, h3 {
width: auto;
left: 0;
right: 0;
}
/* purgecss ignore */
.algolia-autocomplete .ds-dropdown-menu {
min-width: 400px;
/* purgecss ignore */
.algolia-autocomplete .ds-dropdown-menu {
min-width: 350px;
max-width: 470px;
}
}
.search-form {
width: auto;
}
.docs-logo-wrapper {
.site-logo {
width: 180px;
span:nth-child(3) {
font-size: 0.9rem;
}
}
}
}
code[class*="language-"], pre[class*="language-"] {
@ -229,9 +279,14 @@ code[class*="language-"], pre[class*="language-"] {
background: #f5f6f8;
color: #5d6778;
text-shadow: none;
}
.algolia-autocomplete {
width: 100%;
}
header {
.algolia-autocomplete {
width: 100%;
.ds-dropdown-menu {
min-width: 535px;
}
}
}
.gatsby-highlight {
margin: 2rem 0;