about summary refs log tree commit diff
path: root/users/grfn/bbbg/src/bbbg/styles.clj
blob: fd341a62dd5b6ebae2b8e6c7579ab86915ad3094 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
;; -*- eval: (rainbow-mode) -*-
(ns bbbg.styles
  (:require
   [garden.color :as color]
   [garden.compiler :refer [compile-css]]
   [garden.def :refer [defstyles]]
   [garden.selectors :refer [& active attr= descendant hover focus nth-child]]
   [garden.stylesheet :refer [at-media]]
   [garden.units :refer [px]]))

(def black "#342e37")

(def silver "#f9fafb")

(def gray "#aaa")

(def gray-light "#ddd")

(def purple "#837aff")

(def red "#c42348")

(def orange "#fa824c")

(def yellow "#FACB0F")

(def blue "#026fb1")

(def green "#87E24B")

(def contextual-colors
  {:success green
   :info blue
   :warning yellow
   :error red})

;;;

(def content-width (px 1200))

(defn not-mobile [& rules]
  (at-media
   {:screen true
    :min-width content-width}
   [:&
    rules]))

;;;

(defstyles global-nav
  [:.global-nav
   {:background-color silver}

   [:>ul
    {:display :flex
     :flex-direction :row
     :list-style :none}

    (not-mobile
     {:width content-width
      :margin "0 auto"})]

   [:a (descendant :.link-form (attr= "type" "submit"))
    {:padding "1rem 1.5rem"
     :display :block
     :color black
     :text-decoration :none}

     [(& hover)
      {:color blue}]]

   [:li.active
    {:font-weight "bold"
     :border-bottom [["1px" "solid" black]]}]

   [:.spacer
    {:flex 1}]])

(def link-conditional-styles
  (list
   [(& hover) (& active)
    {:text-decoration :underline}]
   [(& active)
    {:color purple}]))

(defstyles link-form
  [:form.link-form
   {:margin 0}
   [(attr= "type" "submit")
    {:background "none"
     :border "none"
     :padding 0
     :color blue
     :text-decoration :none
     :cursor :pointer}
    link-conditional-styles]])

(defstyles search-form
  [:.search-form
   {:display :flex
    :flex-direction :row
    :width "100%"
    :padding "0 1rem"}

   [:>*+*
    {:margin-left "0.75rem"}]

   [:input
    {:flex 1}]

   [(attr= "type" "submit")
    {:flex 0}]])

(defstyles forms
  (let [text-input-types
        #{"date"
          "datetime-local"
          "email"
          "month"
          "number"
          "password"
          "search"
          "tel"
          "text"
          "time"
          "url"
          "week"}
        each-text-type (fn [& rules]
                         (into
                          []
                          (concat
                           (map (comp & (partial attr= "type"))
                                text-input-types)
                           rules)))]
    (each-text-type
     {:width "100%"
      :display "block"
      :padding "0.6rem 0.75rem"
      :border [["1px" "solid" gray-light]]
      :border-radius "3px"
      :box-shadow [["inset" 0 "1px" "5px" "rgba(0,0,0,0.075)"]]
      :transition "border-color 150ms"
      :background "none"}
     [(& focus)
      {:outline "none"
       :border-color purple}]))

  [(attr= "type" "submit") :button
   {:background-color (color/lighten blue 30)
    :padding "0.6rem 0.75rem"
    :border-radius "3px"
    :border [[(px 1) "solid" (color/lighten blue 30)]]
    :cursor :pointer}
   [(& hover)
    {:border-color blue}]
   [(& active)
    {:background-color blue
     :color :white}]])

(defstyles tables
  [:table
   {:width "100%"
    :border-collapse "collapse"}]

  [:th
   {:text-align "left"}]

  [:td :th
   {:padding "0.75rem 1rem"
    :border-spacing 0
    :border "none"}]

  [:tr
   {:border-spacing 0
    :border "none"}
   [(& (nth-child :even))
    {:background-color silver}]])

(defstyles flash
  [:.flash-messages
   {:width "800px"
    :margin "1rem auto"}]

  [:.flash-message
   {:padding "1rem 1.5rem"
    :border "1px solid"
    :margin-bottom "1rem"}]

  (for [[context color] contextual-colors]
    [(& (keyword (str ".flash-" (name context))))
     {:border-color color
      :background-color (color/lighten color 30)
      :border-radius "3px"}]))

(defstyles home-page
  [:.home-page
   {:display :flex
    :flex 1
    :justify-content :center
    :align-items :center}
   [:.signup-form-link
    {:display :block
     :padding "5rem"
     :border [["1px" :solid blue]]
     :border-radius "3px"
     :color black
     :font-size "2rem"
     :background-color (color/lighten blue 50)}
    [(& hover) (& active)
     {:text-decoration :none}]
    [(& active)
     {:background-color (color/lighten blue 30)}]]])

(defstyles styles
  forms
  tables
  global-nav
  link-form
  search-form
  flash
  home-page

  [:body
   {:color black}]

  [:.content
   {:display :flex
    :flex-direction :column
    :height "100%"
    :width "100%"}]

  [:.page
   {:margin-top "1rem"}

   (not-mobile
    {:width content-width
     :margin-left "auto"
     :margin-right "auto"})]

  [:a {:color blue
       :text-decoration :none}
   link-conditional-styles])

(def stylesheet
  (compile-css styles))