GithubHelp home page GithubHelp logo

doggo's Introduction

Doggo

Hex CI Coverage Status

Illustration of a happy Shiba Inu dog wearing a traditional Japanese kimono. The dog is centered within a circular frame, adorned with decorative patterns that include waves and stripes, indicative of a Japanese aesthetic. The Shiba Inu is smiling with its tongue out, suggesting a cheerful and playful demeanor. The kimono features bold red and white accents, complementing the dog's tan and white fur.

Headless UI component collection for Phoenix, focused on semantics and accessibility.

For a full list of available components, please refer to the documentation.

Installation

The package can be installed by adding doggo to your list of dependencies in mix.exs:

def deps do
  [
    {:doggo, "~> 0.5.0"}
  ]
end

Gettext

To allow Doggo to translate certain strings such as form field errors with Gettext, set your Gettext module in config/config.exs:

config :doggo, gettext: MyApp.Gettext

This only affects the input component. If you prefer, you can pass the gettext module as an attribute to the component instead.

Storybook

The library is equipped with story modules for Phoenix Storybook. After you followed the installation instructions of Phoenix Storybook, you can configure a storybook module for Doggo in your application as follows:

defmodule MyAppWeb.Storybook.Doggo do
  use PhoenixStorybook,
    otp_app: :my_app_web,
    content_path: Path.join(:code.priv_dir(:doggo), "/storybook"),
    title: "Doggo Storybook",
    css_path: "/assets/storybook.css",
    js_path: "/assets/storybook.js",
    sandbox_class: "my-app-web"
end

The important option here is content_path, which points to the storybook directory in the priv folder of Doggo. Adjust the rest of the option to the needs of your application.

In your router, add the Doggo storybook as a second storybook and change the path of your application storybook to avoid path conflicts.

scope "/", MyAppWeb do
  pipe_through :browser

  live_storybook("/storybook/app", backend_module: MyAppWeb.Storybook)

  live_storybook("/storybook/doggo",
    backend_module: MyAppWeb.Storybook.Doggo,
    session_name: :live_storybook_doggo,
    pipeline: false
  )
end

PurgeCSS

If you use PurgeCSS, you will need to add deps/doggo/lib/doggo.ex to your PurgeCSS configuration.

Doggo also uses modifier CSS classes to alter the appearance of components. The class names are generated dynamically, which means PurgeCSS won't be able to find them in the source code. You can use mix dog.modifiers to save a list of all modifier class names to a file:

mix dog.modifiers -o assets/modifiers.txt

Add the generated file to your PurgeCSS configuration as well.

Design decisions

  • Favor semantic HTML elements over CSS classes for structure and clarity.
  • Adhere to accessibility guidelines with appropriate ARIA attributes and roles.
  • Utilize semantic HTML and ARIA attributes for style bindings to states, rather than relying on CSS classes.
  • Where state or variations can not be expressed semantically, use modifier classes named .is-* or .has-*.
  • The library is designed without default styles and does not prefer any particular CSS framework.

Demo app

The repository contains a demo application that renders the plain storybook. Note that it doesn't come with any CSS, so all components will be rendered with default browser styles.

git clone [email protected]:woylie/doggo.git
cd doggo/demo
mix setup
mix phx.server

The storybook can be accessed at http://localhost:4000.

Status

The library is actively developed. Being in its early stages, the library may still undergo significant changes, potentially leading to breaking changes.

If you miss a component, if you have trouble with an existing component, or if a component doesn't work for you in a certain use case, please don't hesitate to open a Github issue.

doggo's People

Contributors

dependabot[bot] avatar woylie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

doggo's Issues

JS and Keyboard interaction

After completing the initial component set (#20) on the semantic level, the next step will be to add (keyboard) interaction where applicable. We'll mainly follow the APG patterns.

  • tabs
    • left arrow: move focus to previous tab
    • right arrow: move focus to next tab
    • home: move focus to first tab
    • end: move focus to last tab
  • accordion
    • toggle visibility on click
  • toggle button
    • allow client-side state handling
  • disclosure button
    • toggle visibility and aria-expanded
  • tree (see https://www.w3.org/WAI/ARIA/apg/patterns/treeview/)
    • keyboard navigation, tabindex
    • select (single, multiple; leaf only or parent and leaf)
    • expand/collapse
    • lazy load children
  • toolbar (see https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/)
    • move focus with left/right arrow key
  • carousel
    • Handle previous/next buttons
    • Handle pagination tabs
    • Auto rotation
    • Disable auto rotation when controls are used
    • Disable previous/next button on first/last item.
    • Focus management and keyboard support for pagination
  • combobox
  • menu, menubar, menubutton
  • split pane
  • action bar
  • menu
  • menu bar
  • menu group
  • menu item checkbox
  • menu item radio group

Make button have loading and disabled tate.

Is your feature request related to a problem? Please describe.

For loading state, disable the button and show loading icon.

Describe the solution you'd like
Allow attributes loading and disabled on the button. https://github.com/woylie/doggo/blob/main/lib/doggo.ex#L220

Consider using slots for a custom implementation of loading icon.

Describe alternatives you've considered
Since using native HTML is preferred, disabled attribute would work fine. However, for loading state, a slot has to be populated.

Additional context
Willing to raise the PR for the same.

add component stories

  • alert
  • card
  • fallback
  • icon
  • icon_sprite
  • input
  • label
  • field_errors
  • field_description
  • modal
  • navbar
  • switch
  • table
  • drawer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.