Skip to content

CSS: file-drop

.instui-file-drop — พื้นที่วางไฟล์ที่มีสถานะโฮเวอร์ ยอมรับ และปฏิเสธ

คลาส -hover/-accepted/-rejected เป็นเพียงด้านภาพเท่านั้น — การตรวจจับการลากแล้วปล่อยจริงและการตรวจสอบไฟล์เป็นงานของ JS ฝั่งผู้ใช้ที่ต้องเชื่อมรอบๆ input แบบ native ที่ห่อไว้

Source: file-drop.css

การเข้าถึง

ห่อ <input type="file"> แบบ native ไว้ในเขตวางไฟล์ <label> เพื่อให้ยังคงเป็นคอนโทรลไฟล์ที่แท้จริง มีป้ายระบุ และคีย์บอร์ดกับเทคโนโลยีช่วยเหลือสามารถใช้งานได้

การใช้งาน

css
@import "@pantoken/components/components.css";
@import "@pantoken/components/file-drop.css";

ตัวอย่าง

html
<label class="instui-file-drop" id="fd">
  <span class="instui-icon -icon-cloud-upload"></span>
  <div class="instui-text"><strong>Drag an image here</strong>, or click to browse.</div>
  <div class="instui-text -size-sm instui-fg-muted" id="fd-msg">PNG or JPG up to 5&nbsp;MB.</div>
  <input type="file" id="fd-input">
</label>

โครงสร้าง

text
.instui-file-drop
  [class*="-icon-"] (0..1)
  text (component)
    strong
  text (component)
  input
flowchart TD n0[".instui-file-drop"]:::cssdoc-root n1("[class*=&quot;-icon-&quot;]"):::cssdoc-part n2(["text"]):::cssdoc-component n3("strong"):::cssdoc-part n4(["text"]):::cssdoc-component n5("input"):::cssdoc-part n0 -.->|0..1| n1 n2 --> n3 n0 --> n2 n0 --> n4 n0 --> n5 click n2 "/api/css/text.md" click n4 "/api/css/text.md" classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

ตัวปรับแต่ง

ตัวปรับแต่งคำอธิบาย
.-acceptedสถานะการลากสำหรับไฟล์ที่ยอมรับได้
.-hoverสถานะโฮเวอร์หรือการลากทับ
.-icon-*แสดงไอคอนสัญลักษณ์นำสำหรับพื้นที่วางไฟล์
.-rejectedสถานะการลากสำหรับไฟล์ที่ถูกปฏิเสธ

โทเค็นที่ใช้

Tokenชนิดค่า
--instui-color-text-base<color>LightDarklight-dark(#273540, #F2F4F5)
--instui-component-file-drop-accepted-color<color>LightDarklight-dark(#1D354F, #EEF4FD)
--instui-component-file-drop-background-color<color>LightDarklight-dark(#ffffff, #1C222B)
--instui-component-file-drop-border-color<color>LightDarklight-dark(#7E8792, #5F6E7A)
--instui-component-file-drop-border-radius<length>1rem
--instui-component-file-drop-border-styledashed
--instui-component-file-drop-border-width<length>0.0625rem
--instui-component-file-drop-hover-border-color<color>LightDarklight-dark(#1D354F, #EEF4FD)
--instui-component-file-drop-rejected-color<color>LightDarklight-dark(#CF1F24, #F56050)
--instui-spacing-space-lg<length>1rem

ส่วนประกอบย่อย