From 593dbd2d42fd2409cf6aede77fb3f1130ef37db2 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Wed, 27 Aug 2014 17:42:14 -0400 Subject: [PATCH] Add some style to attachments (thanks @uptonic) --- assets/demo.html | 98 ++++++++++++++------ assets/file_icon.png | Bin 0 -> 2696 bytes src/trix/views/file_attachment_view.coffee | 2 + src/trix/views/image_attachment_view.coffee | 1 + 4 files changed, 72 insertions(+), 29 deletions(-) create mode 100644 assets/file_icon.png diff --git a/assets/demo.html b/assets/demo.html index 4ead7de8..da179844 100644 --- a/assets/demo.html +++ b/assets/demo.html @@ -35,6 +35,75 @@ padding: 0; } + figure.attachment { + position: relative; + padding: 0; + margin: 0; + } + + figure.attachment.file { + border-radius: .4rem; + border: 1px solid rgba(0,0,0,0.15); + font-size: 1em; + overflow: hidden; + padding: 1rem 1.5rem; + position: relative; + text-overflow: ellipsis; + white-space: nowrap; + } + + figure.attachment.file:before { + position: relative; + content: ''; + display: inline-block; + height: 3.6rem; + width: 3rem; + vertical-align: middle; + z-index: 1; + background-image: url("/file_icon.png"); + background-size: auto 100%; + background-repeat: no-repeat; + } + + figure.attachment.file figcaption { + position: relative; + white-space: nowrap; + vertical-align: middle; + display: inline-block; + z-index: 1; + } + + figure.attachment.file span.size { + color: #aa9c84; + margin-left: 1rem; + } + + figure.attachment.image img { + position: relative; + z-index: 1; + } + + figure.attachment progress[value] { + -webkit-appearance: none; + appearance: none; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + } + + figure.attachment progress[value]::-webkit-progress-bar { + background-color: transparent; + border-radius: .6rem; + width: 100%; + } + + figure.attachment progress[value]::-webkit-progress-value { + background-color: #e6f6fc; + border-radius: .4rem 0 0 .4rem; + } + #debug { white-space: pre-wrap; } @@ -91,35 +160,6 @@ display: block; } - .trix-editor figure.attachment { - font-family: monospace; - width: 100px; - margin: 2px 4px; - padding: 5px; - border: 1px solid #BDBDBD; - border-radius: 3px; - display: inline-block; - } - - .trix-editor .attachment .extension { - background-color: #BDBDBD; - color: white; - border-radius: 3px; - text-transform: uppercase; - font-size: 2em; - text-align: center; - padding: 8px 0; - margin-bottom: 5px; - } - - .trix-editor .attachment figcaption { - font-size: .8em; - display: block; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - textarea.debug { width: 90%; max-width: 450px; diff --git a/assets/file_icon.png b/assets/file_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..50efaa6723e304a7e1d0e2dd827648159334d655 GIT binary patch literal 2696 zcmb7Gc{Cg77LRGEt)yC_N+nb^wn#A=HBv!qk0shtl*Be-D`RVQvxWv$JEb-D*HF^Z zir6DDLX9Q1jJ>UWtJVZ5FFo_#ym#K2Kj!`Q-Fv=!f4|?o_dDmii8j_(jta{N0|0=d zW~Rn=yps+9@Bst`c-Df8&?Nvs7;R>3h=~|qovs`KA*Sc-P(lhykASG4W9Gl0 zqGN$5kcM-djX6l6h(I_jq+|+pdAg?`E~uaYF@1dgMUiNcsg#T9FIXRH`0GvyW8;!8 zun7v71}y2)91U4>PVaBXYuKeu?(MY8pFPt6>)W|IkC@k=f0~bUm3+$(s8%qFk=#N8Pk)4#vxD%jWa+|gNVX3Vv4 zJux{`$7 z&s*~ccxVW;Zz^r2{Q1c0S`z3JMbqlN=rDY+5glCKMHZjqcRu!WVs%S__zdF5DK2r4 z`m3echn><82=&ZP>I_Qo#+>>#vDI?wZSmAic=TK=^?PldRUvgDfZOT1CHhvQG)5WC7$QqUo)8L@iT+7P@6IInB zWxH8tp!)MHUR}RB{@KorV2l!d+4=ky%H) z`1G8Vn&UyqBIs7pf@8&N$*cN!|3PG($IJ|)w+Z)tr!%@`#kQa1LNro$%Dh9p1q$MD zXRV83)&jz_eTFB0n4BUjE%)wvj*HB6{(PXBh?6^YixKfMZV!>CctuEj`(r2h7f zIkKTQXIOQ=CdRSWFIKw6e{)e$IZtz{>E$#m%v9|Z_;TR^h;|P5>NuPL zZwuz8NrUM=2r-F6H0jWqh^(*iJfBWs_iatk0PydJ-+Tq$ z1UNr!`-0L6&VaoTc2k*NBHn5g;aLMRoMu$c(Q;B6>9+3jfk0~_^d$Z>d4<@TY76mG zrk{9R2Enm=M81}3QPZUdhpL?R*i#3`_N};P0a#1-5tVvdzZYYp+s`_kR>JkX@f9Jq zL-!e!6G$dY+d*deGAX}yZK(NLjI@u>@9W-+8_^v09dwV6H#o?o{fsi<;cyTnwrcTB zBx#uj_BG`+g4S$e~OLoKpPOVF~ zC<<(B$SL;SHxZql$*rtY(x3qde859sflHzfqycaOAC@;JumG=xyvczD;Fm03+wyZZk(hL`*= zpgibh?u=;~YVa zE<=@u6LT7(8}0VIvOaMOqC0a~n2PJfF;pkPy60){)*BHioU45i7XI;3Pf#$n4AlOJ z|M$M;W>C9Uo`}O^a@P54KJmQA4oW!)DxZe3UGhXTMX9)9;kC`*cJ@JcWLY=WIGw4! z=P^UcdQKaprOq#~W}6!65m>?o$;&9WgjhubL~`8JE)mVt6bWs~lHYOD+h%0*JvrP@U{k#BFz z=D*a}loRj^cwTT?nUs;kY=rKmu6KBjRZ1XRzk16)Y6=K1Kg+e zHS}e4?b^fIz`&S!nSyr+kd2i`ryp`Np2GXDFyP#sWMY@xO8b1RoWpY ze7iNco!=qd2Fi@HDlcumE?e<5%-w-`gk3IztWfk`F=X=lmPLxQ%4ws<7Hm zRt$uvixt{=jhzHJ*LhgpDkHN_Jc9T^cR%Zvnpf;(u)0Uy((bVnB-Jlqd`WQ+q4}Y( zqmvG^)hea*N%irZbj@s3#J#r);SL=Yc`BZP8lJVcm element = super + element.classList.add("file") + caption = document.createElement("figcaption") caption.textContent = @attachmentPiece.getFilename() diff --git a/src/trix/views/image_attachment_view.coffee b/src/trix/views/image_attachment_view.coffee index d9d847e9..20eb0c61 100644 --- a/src/trix/views/image_attachment_view.coffee +++ b/src/trix/views/image_attachment_view.coffee @@ -3,6 +3,7 @@ class Trix.ImageAttachmentView extends Trix.AttachmentView render: -> element = super + element.classList.add("image") image = document.createElement("img") if @attachmentPiece.isPending()