Browse Source

Scale width of download buttons by size

ghorsington 4 năm trước cách đây
mục cha
commit
aae7f33d37
3 tập tin đã thay đổi với 14 bổ sung2 xóa
  1. 4 0
      src/app.py
  2. 9 1
      src/static/style/main.scss
  3. 1 1
      src/templates/project_view.html

+ 4 - 0
src/app.py

@@ -21,6 +21,7 @@ assets.register('scss_all', scss)
 class ArtifactItem:
     file: str
     description: str
+    width: int = 0
 
     def __init__(self, file, description):
         self.file = file
@@ -39,6 +40,9 @@ class Artifact:
         self.changelog = changelog
         self.artifacts = [ArtifactItem(**item)
                           for item in artifacts]
+        maxwidth = max((len(a.file) for a in self.artifacts), default=0)
+        for a in self.artifacts:
+            a.width = maxwidth
 
     @classmethod
     def from_json(cls, json_str):

+ 9 - 1
src/static/style/main.scss

@@ -31,10 +31,13 @@ $menu-label-color: hsl(0, 0%, 96%);
     width: inherit;
     top: $navbar-height + $column-gap;
     padding-right: $column-gap * 3;
-    user-select: none;
   }
 }
 
+aside#project-menu {
+  user-select: none;
+}
+
 @media (max-width: $tablet) {
   div#ci-menu {
     padding-right: 1.5rem;
@@ -72,6 +75,11 @@ hr.content-divider {
   height: 1px;
 }
 
+table td.min-size {
+  width: 1%;
+  white-space: nowrap;
+}
+
 div.artifact-item {
   $artifact-item-radius: 2px;
   margin-bottom: 0.75rem;

+ 1 - 1
src/templates/project_view.html

@@ -55,7 +55,7 @@
                     <tbody>
                         {%-for download_item in artifact.artifacts%}
                         <tr>
-                            <td><a class="button is-link" href="{{ url_for('download_item', project_id=selected_project.id, artifact_id=artifact.id, download_item=download_item.file)}}">{{download_item.file}}</a></td>
+                            <td class="min-size"><a class="button is-link" style="width: calc({{download_item.width}} * 0.6rem);" href="{{ url_for('download_item', project_id=selected_project.id, artifact_id=artifact.id, download_item=download_item.file)}}">{{download_item.file}}</a></td>
                             <td>{{download_item.description}}</td>
                         </tr>
                         {%-endfor%}