Commit 7911b511d193bfabd39ac967aecdc0570f2f452e
styling: tabs, search
mix irving committed on 4/2/2017, 7:12:47 AMParent: 4d3cb91c6ee16940192ca26735e900f4fe57ac80
Files changed
main/html/app.js | changed |
main/html/hypertabs.mcss | changed |
main/html/menu.mcss | changed |
main/html/search.js | deleted |
main/html/search-bar.js | added |
main/html/search.mcss | deleted |
main/html/search-bar.mcss | added |
main/html/app.js | ||
---|---|---|
@@ -13,9 +13,9 @@ | ||
13 | 13 | html: { |
14 | 14 | error: 'first', |
15 | 15 | externalConfirm: 'first', |
16 | 16 | menu: 'first', |
17 | - search: 'first' | |
17 | + searchBar: 'first' | |
18 | 18 | }, |
19 | 19 | sync: { |
20 | 20 | catchKeyboardShortcut: 'first' |
21 | 21 | } |
@@ -39,9 +39,9 @@ | ||
39 | 39 | |
40 | 40 | addPage(path, true, false) |
41 | 41 | return change |
42 | 42 | } |
43 | - const search = api.main.html.search(handleSelection) | |
43 | + const search = api.main.html.searchBar(handleSelection) | |
44 | 44 | const menu = api.main.html.menu(handleSelection) |
45 | 45 | |
46 | 46 | const tabs = Tabs(onSelect, { append: h('div.navExtra', [ search, menu ]) }) |
47 | 47 | function onSelect (indexes) { |
main/html/hypertabs.mcss | ||
---|---|---|
@@ -25,17 +25,20 @@ | ||
25 | 25 | font-size: .9rem |
26 | 26 | background-color: #efefef |
27 | 27 | overflow: hidden |
28 | 28 | |
29 | - padding: 0 .4rem | |
29 | + padding: 0 | |
30 | 30 | margin-left: .6rem |
31 | 31 | border: 1px gainsboro solid |
32 | 32 | border-bottom: none |
33 | 33 | |
34 | 34 | -selected { |
35 | 35 | color: #222 |
36 | 36 | background-color: #fff |
37 | 37 | |
38 | + a.link { | |
39 | + max-width: calc(100% - 2rem) | |
40 | + } | |
38 | 41 | a.close { |
39 | 42 | visibility: visible |
40 | 43 | } |
41 | 44 | } |
@@ -58,18 +61,35 @@ | ||
58 | 61 | flex-grow: 1 |
59 | 62 | flex-shrink: 0 |
60 | 63 | overflow-x: hidden |
61 | 64 | min-width: 0 |
62 | - max-width: 90% | |
65 | + max-width: calc(100% - 1.4rem) | |
63 | 66 | white-space: nowrap |
64 | 67 | text-overflow: ellipsis |
65 | 68 | |
66 | - padding: 0.5rem .2rem | |
69 | + padding: .5rem 0 .5rem .6rem | |
67 | 70 | } |
68 | 71 | |
69 | 72 | a.close { |
70 | 73 | visibility: hidden |
74 | + font-family: monospace | |
75 | + line-height: 1rem | |
76 | + width: .9rem | |
77 | + height: .9rem | |
78 | + /* border-radius: 1rem */ | |
79 | + | |
80 | + margin-right: .3rem | |
81 | + | |
82 | + display: flex | |
83 | + justify-content: center | |
84 | + | |
85 | + :hover { | |
86 | + background: #aaaaaa | |
87 | + color: #fff | |
88 | + font-weight: 600 | |
89 | + } | |
71 | 90 | } |
91 | + | |
72 | 92 | } |
73 | 93 | |
74 | 94 | } |
75 | 95 |
main/html/menu.mcss | ||
---|---|---|
@@ -3,24 +3,19 @@ | ||
3 | 3 | width: .7rem |
4 | 4 | height: .7rem |
5 | 5 | border-radius: 1rem |
6 | 6 | |
7 | - margin-right: .5rem | |
7 | + margin: 0 .5rem | |
8 | 8 | |
9 | 9 | div { |
10 | 10 | display: none |
11 | 11 | |
12 | 12 | position: absolute |
13 | 13 | top: .5em |
14 | 14 | right: 0 |
15 | - padding-top: .5em | |
16 | - padding-bottom: .5em | |
17 | - padding-right: 1em | |
18 | - padding-left: 1em | |
19 | - background: #f5f5f5 | |
20 | - border: 1px solid #eee | |
15 | + padding: 2rem 1rem .5rem | |
16 | + background: linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0) 1.5rem, #f5f5f5 1.5rem, #f5f5f5) | |
21 | 17 | z-index: 5 |
22 | - | |
23 | 18 | } |
24 | 19 | |
25 | 20 | -active { |
26 | 21 | div { |
main/html/search.js | ||
---|---|---|
@@ -1,68 +1,0 @@ | ||
1 | -const nest = require('depnest') | |
2 | -const { h } = require('mutant') | |
3 | -const addSuggest = require('suggest-box') | |
4 | - | |
5 | -exports.gives = nest('main.html.search') | |
6 | - | |
7 | -exports.needs = nest({ | |
8 | - 'about.async.suggest': 'first', | |
9 | - 'channel.async.suggest': 'first' | |
10 | -}) | |
11 | - | |
12 | -exports.create = function (api) { | |
13 | - return nest('main.html.search', search) | |
14 | - | |
15 | - function search (go) { | |
16 | - const getProfileSuggestions = api.about.async.suggest() | |
17 | - const getChannelSuggestions = api.channel.async.suggest() | |
18 | - | |
19 | - const input = h('input', { | |
20 | - type: 'search', | |
21 | - placeholder: '?search, @name, #channel', | |
22 | - 'ev-keyup': ev => { | |
23 | - switch (ev.keyCode) { | |
24 | - case 13: // enter | |
25 | - if (go(input.value.trim(), !ev.ctrlKey)) { | |
26 | - input.blur() | |
27 | - } | |
28 | - return | |
29 | - case 27: // escape | |
30 | - ev.preventDefault() | |
31 | - input.blur() | |
32 | - return | |
33 | - } | |
34 | - } | |
35 | - }) | |
36 | - input.go = go // crude navigation api | |
37 | - input.addEventListener('suggestselect', ev => { | |
38 | - input.value = ev.detail.id // HACK : this over-rides the markdown value | |
39 | - | |
40 | - // if (go(input.value.trim(), !ev.ctrlKey)) | |
41 | - // input.blur() | |
42 | - }) | |
43 | - const search = h('Search', input) | |
44 | - | |
45 | - search.input = input | |
46 | - search.activate = (sigil, ev) => { | |
47 | - input.focus() | |
48 | - ev.preventDefault() | |
49 | - if (input.value[0] === sigil) { | |
50 | - input.selectionStart = 1 | |
51 | - input.selectionEnd = input.value.length | |
52 | - } else { | |
53 | - input.value = sigil | |
54 | - } | |
55 | - } | |
56 | - | |
57 | - addSuggest(input, (inputText, cb) => { | |
58 | - if (inputText[0] === '@') { | |
59 | - cb(null, getProfileSuggestions(inputText.slice(1))) | |
60 | - } else if (inputText[0] === '#') { | |
61 | - cb(null, getChannelSuggestions(inputText.slice(1))) | |
62 | - } | |
63 | - }, {cls: 'SuggestBox'}) | |
64 | - | |
65 | - return search | |
66 | - } | |
67 | -} | |
68 | - |
main/html/search-bar.js | ||
---|---|---|
@@ -1,0 +1,68 @@ | ||
1 | +const nest = require('depnest') | |
2 | +const { h } = require('mutant') | |
3 | +const addSuggest = require('suggest-box') | |
4 | + | |
5 | +exports.gives = nest('main.html.searchBar') | |
6 | + | |
7 | +exports.needs = nest({ | |
8 | + 'about.async.suggest': 'first', | |
9 | + 'channel.async.suggest': 'first' | |
10 | +}) | |
11 | + | |
12 | +exports.create = function (api) { | |
13 | + return nest('main.html.searchBar', search) | |
14 | + | |
15 | + function search (go) { | |
16 | + const getProfileSuggestions = api.about.async.suggest() | |
17 | + const getChannelSuggestions = api.channel.async.suggest() | |
18 | + | |
19 | + const input = h('input', { | |
20 | + type: 'search', | |
21 | + placeholder: '?search, @name, #channel', | |
22 | + 'ev-keyup': ev => { | |
23 | + switch (ev.keyCode) { | |
24 | + case 13: // enter | |
25 | + if (go(input.value.trim(), !ev.ctrlKey)) { | |
26 | + input.blur() | |
27 | + } | |
28 | + return | |
29 | + case 27: // escape | |
30 | + ev.preventDefault() | |
31 | + input.blur() | |
32 | + return | |
33 | + } | |
34 | + } | |
35 | + }) | |
36 | + input.go = go // crude navigation api | |
37 | + input.addEventListener('suggestselect', ev => { | |
38 | + input.value = ev.detail.id // HACK : this over-rides the markdown value | |
39 | + | |
40 | + // if (go(input.value.trim(), !ev.ctrlKey)) | |
41 | + // input.blur() | |
42 | + }) | |
43 | + const search = h('SearchBar', input) | |
44 | + | |
45 | + search.input = input | |
46 | + search.activate = (sigil, ev) => { | |
47 | + input.focus() | |
48 | + ev.preventDefault() | |
49 | + if (input.value[0] === sigil) { | |
50 | + input.selectionStart = 1 | |
51 | + input.selectionEnd = input.value.length | |
52 | + } else { | |
53 | + input.value = sigil | |
54 | + } | |
55 | + } | |
56 | + | |
57 | + addSuggest(input, (inputText, cb) => { | |
58 | + if (inputText[0] === '@') { | |
59 | + cb(null, getProfileSuggestions(inputText.slice(1))) | |
60 | + } else if (inputText[0] === '#') { | |
61 | + cb(null, getChannelSuggestions(inputText.slice(1))) | |
62 | + } | |
63 | + }, {cls: 'SuggestBox'}) | |
64 | + | |
65 | + return search | |
66 | + } | |
67 | +} | |
68 | + |
Built with git-ssb-web