從左至右 / 從右至左

一個 Storybook 工具擴充功能,用於在 LTR 和 RTL 之間切換 html dir 屬性。

在 Github 上檢視

storybook-addon-rtl-direction

一個 Storybook 工具擴充功能,用於在 LTR 和 RTL 之間切換 html dir 屬性。

  • dir="ltr"dir="rtl" 樣式將會被添加到 html 標籤中,並在工具區顯示 LTR/RTL 圖示。

Example

安裝

npm i --save-dev storybook-addon-rtl-direction

將其添加到 .storybook/main.js

module.exports = {
  addons: ["storybook-addon-rtl-direction"],
};

使用語系

您可以與語系同步以設定預設方向。

// preview.js

export const globalTypes = {
  locale: {
    name: "Locale",
    description: "Internationalization locale",
    defaultValue: "en",
    toolbar: {
      icon: "globe",
      items: [
        { value: "en-US", right: "LTR", title: "English (United States)" },
        { value: "es", right: "LTR", title: "Spanish" },
        { value: "ar", right: "RTL", title: "Arabic" },
        { value: "ar-OM", right: "RTL", title: "Arabic (Oman)" },
        { value: "pa-IN", right: "LTR", title: "Punjabi (India)" },
        { value: "pa-PK", right: "RTL", title: "Punjabi (Pakistan)" },
      ],
    },
  },
};

export const parameters = {
  rtlDirection: {
    // Collection to set as RTL (You can add language or with add country code specifically)
    autoLocales: ["ar", "pa-PK"],
    // Condition to reload the page each time locale is updated
    reload: true,
  },
};

https://user-images.githubusercontent.com/588874/194731628-07124805-cc11-4acb-bb45-0aa24d53c625.mov

  • mayognaise
    mayognaise
適用於
    Angular
    Ember
    HTML
    Preact
    React
    Svelte
    Vue
    Web Components
標籤