Browse Source

Style tweaks, add site_name setting

master
Dylan Baker 5 years ago
parent
commit
e7bf107409

+ 101
- 45
assets/scss/style.scss View File

@@ -1,3 +1,17 @@
1
+/* variables */
2
+
3
+$black:       #000000;
4
+$white:       #ffffff;
5
+$blue:        #496893;
6
+$red:         #ff0000;
7
+$light-gray:  #f5f5f5;
8
+$medium-gray: #c8c8c8;
9
+
10
+$body-font-family: Georgia, serif;
11
+
12
+$body-font-size:    18px;
13
+$heading-font-size: 26px;
14
+
1 15
 /* global */
2 16
 
3 17
 * {
@@ -11,76 +25,92 @@ ul {
11 25
 }
12 26
 
13 27
 a {
28
+  color: $blue;
14 29
   text-decoration: none;
30
+
31
+  &:hover {
32
+   text-decoration: underline;
33
+  }
34
+}
35
+
36
+body {
37
+  font-family: $body-font-family;
38
+  font-size: $body-font-size;
39
+  line-height: 1.5;
40
+  min-height: 100vh;
15 41
 }
16 42
 
17 43
 .heading {
18
-  border-bottom: 1px solid #000000;
19
-  font-size: 24px;
44
+  border-bottom: 1px solid $black;
45
+  font-size: $heading-font-size;
20 46
   margin-bottom: 15px;
21 47
 }
22 48
 
23 49
 /* layout */
24 50
 
25 51
 .container {
52
+  border-left: 1px solid $medium-gray;
53
+  border-right: 1px solid $medium-gray;
26 54
   display: flex;
55
+  flex-direction: column;
56
+  margin: auto;
57
+  max-width: 768px;
58
+  min-height: 100vh;
27 59
 }
28 60
 
29 61
 .main {
62
+  background: $light-gray;
30 63
   display: flex;
31 64
   flex: 1;
32
-  justify-content: center;
33 65
   padding: 20px;
66
+  width: 100%;
34 67
 }
35 68
 
36
-.main__container {
37
-  width: 768px;
38
-}
69
+/* header */
70
+.header {
71
+  background: $blue;
72
+  color: $white;
39 73
 
40
-/* sidebar */
41
-.sidebar {
42
-  background: #496893;
43
-  color: #ffffff;
44
-  min-height: 100vh;
45
-  padding: 20px 0;
46
-  width: 150px;
74
+  @media(max-width: 1000px) {
75
+    min-height: auto;
76
+    width: 100%;
77
+  }
47 78
 }
48 79
 
49
-.sidebar__title {
50
-  color: #ffffff;
80
+.header__title {
81
+  color: $white;
51 82
   font-size: 24px;
83
+  padding: 15px;
52 84
 }
53 85
 
54
-.sidebar__title,
55
-.nav__item {
56
-  padding: 5px 10px;
57
-}
58
-
59
-.nav__item:hover {
60
-  background: #ffffff;
86
+.nav {
87
+  background: $white;
88
+  display: flex;
89
+  justify-content: space-between;
90
+  padding: 10px 0;
61 91
 }
62 92
 
63
-.nav__item:hover a {
64
-  color: #496893;
93
+.nav__item {
94
+  padding: 5px 10px;
65 95
 }
66 96
 
67
-.nav__link {
68
-  color: white;
69
-}
97
+/* forms */
70 98
 
71
-.nav__link:hover {
72
-  text-decoration: underline;
99
+.form {
100
+  width: 100%;
73 101
 }
74 102
 
75
-/* forms */
76
-
77 103
 .form__field {
78 104
   display: flex;
79 105
   flex-direction: column;
80
-  margin: 5px 0;
106
+  margin: 15px 0;
81 107
   width: 100%;
82 108
 }
83 109
 
110
+.form__field--submit {
111
+  display: block;
112
+}
113
+
84 114
 .form__field,
85 115
 .form__label {
86 116
   margin-bottom: 5px;
@@ -89,34 +119,60 @@ a {
89 119
 .form__date-field,
90 120
 .form__textarea,
91 121
 .form__text-field {
92
-  border: 1px solid #e8e8e8;
93
-  font-family: serif;
94
-  font-size: 16px;
95
-  padding: 5px;
122
+  border: 1px solid $medium-gray;
123
+  font-family: $body-font-family;
124
+  font-size: $body-font-size;
125
+  padding: 10px;
96 126
 }
97 127
 
98 128
 .form__textarea {
99 129
   resize: vertical;
100 130
 }
101 131
 
102
-.form__submit {
103
-  border: 1px solid #e8e8e8;
104
-  padding: 5px 10px;
132
+.button.form__submit {
133
+  background: $white;
134
+  border: 1px solid $medium-gray;
135
+  cursor: pointer;
136
+  font-family: $body-font-family;
137
+  font-size: $body-font-size;
138
+  padding: 10px;
139
+
140
+  &:hover {
141
+    background: $light-gray;
142
+  }
143
+
144
+  @media(max-width: 500px) {
145
+    width: 100%;
146
+  }
105 147
 }
106 148
 
107 149
 /* post listing */
150
+
151
+.post-listing {
152
+  width: 100%;
153
+}
154
+
108 155
 .post-listing__item {
156
+  display: flex;
157
+  padding: 10px;
109 158
   position: relative;
159
+  width: 100%;
160
+
161
+  &:nth-child(even) {
162
+    background: white;
163
+  }
110 164
 }
111 165
 
112 166
 .post-listing__item--changed:before {
113
-  background-color: red;
114
-  border-radius: 50%;
115
-  content: '';
167
+  color: $red;
168
+  content: '•';
116 169
   display: block;
117
-  height: 10px;
170
+  font-size: $heading-font-size;
118 171
   left: -15px;
172
+  line-height: 16px;
119 173
   position: absolute;
120
-  top: 3px;
121
-  width: 10px;
174
+}
175
+
176
+.post-listing__link {
177
+  flex: 1;
122 178
 }

+ 2
- 1
tests/test_posts.py View File

@@ -16,7 +16,8 @@ def setup():
16 16
     os.mkdir(os.path.join(temp_dir.name, 'public'))
17 17
     with open(os.path.join(temp_dir.name, 'settings.json'), "w") as f:
18 18
         f.write(json.dumps({
19
-            "PUBLIC_PATH": os.path.join(temp_dir.name, 'public')
19
+            "PUBLIC_PATH": os.path.join(temp_dir.name, 'public'),
20
+            "SITE_NAME": "test website"
20 21
         }))
21 22
 
22 23
     # Importing PostsService initializes a Settings object which depends on

+ 2
- 1
tests/test_settings.py View File

@@ -20,7 +20,8 @@ def test_reading_yird_path():
20 20
     os.environ["YIRD_PATH"] = root
21 21
     with open(os.path.join(root, "settings.json"), "w") as f:
22 22
         f.write(json.dumps({
23
-            "PUBLIC_PATH": os.path.join(root, "public")
23
+            "PUBLIC_PATH": os.path.join(root, "public"),
24
+            "SITE_NAME": "test website"
24 25
         }))
25 26
     assert Settings().YIRD_PATH == root
26 27
     shutil.rmtree(root)

+ 7
- 0
yird/app.py View File

@@ -20,6 +20,13 @@ webpack.init_app(app)
20 20
 yird_settings = Settings()
21 21
 
22 22
 
23
+@app.context_processor
24
+def inject_site_name():
25
+    return {
26
+        "site_name": yird_settings.SITE_NAME
27
+    }
28
+
29
+
23 30
 @app.route('/admin')
24 31
 def index():
25 32
     posts = PostsService.get_posts()

+ 1
- 0
yird/settings.py View File

@@ -11,3 +11,4 @@ class Settings:
11 11
         with open(os.path.join(self.YIRD_PATH, 'settings.json')) as f:
12 12
             settings_file = json.loads(f.read())
13 13
             self.PUBLIC_PATH = settings_file['PUBLIC_PATH']
14
+            self.SITE_NAME = settings_file['SITE_NAME']

+ 2
- 2
yird/templates/index.html.j2 View File

@@ -4,10 +4,10 @@
4 4
     <h3 class="heading">all posts</h3>
5 5
     {% for post in posts %}
6 6
       <li class="post-listing__item {% if post.changed %}post-listing__item--changed{% endif %}">
7
-        <span>{{ post.date }}</span>
8
-        <a href="{{ url_for('edit_post', post_id = post.id) }}">
7
+        <a href="{{ url_for('edit_post', post_id = post.id) }}" class="post-listing__link">
9 8
           {{ post.title }}
10 9
          </a>
10
+        <span>{{ post.date }}</span>
11 11
       </li>
12 12
     {% endfor %}
13 13
   </ul>

+ 5
- 7
yird/templates/layout.html.j2 View File

@@ -4,12 +4,12 @@
4 4
   <meta charset="UTF-8">
5 5
   <meta name="viewport" content="width=device-width">
6 6
   <link rel="stylesheet" href="{{ url_for('static', filename=asset_url_for('app_css.css')) }}">
7
-  <title>My Website</title>
7
+  <title>{{ site_name }} - yird</title>
8 8
 </head>
9 9
 <body>
10 10
   <div class="container">
11
-    <aside class="sidebar">
12
-      <h3 class="sidebar__title">yird</h3>
11
+    <header class="header">
12
+      <h3 class="header__title">{{ site_name }}</h3>
13 13
       <ul class="nav">
14 14
      		<li class="nav__item">
15 15
 					<a class="nav__link" href="{{ url_for('index') }}">
@@ -27,11 +27,9 @@
27 27
           </a>
28 28
         </li>
29 29
       </ul>
30
-    </aside>
30
+    </header>
31 31
     <main class="main">
32
-      <div class="main__container">
33
-        {% block content %}{% endblock %}
34
-      </div>
32
+      {% block content %}{% endblock %}
35 33
     </main>
36 34
   </div>
37 35
   <script src="{{ url_for('static', filename=asset_url_for('app_js.js')) }}"></script>

+ 2
- 2
yird/templates/posts/form.html.j2 View File

@@ -21,8 +21,8 @@
21 21
       <label class="form__label">{{ form.content.label }}</label>
22 22
       {{ form.content(class="form__textarea", rows=10) }}
23 23
     </div>
24
-    <div class="form__field">
25
-      <input type="submit" value="Submit" class="form__submit">
24
+    <div class="form__field form__field--submit">
25
+      <input type="submit" value="Submit" class="form__submit button">
26 26
     </div>
27 27
   </form>
28 28
 {% endblock %}

Loading…
Cancel
Save