Giter Club home page Giter Club logo

purescript-ocelot's Introduction

Ocelot CircleCI

Ocelot is an opinionated component library for Halogen-based PureScript applications.

Philosophy

This repository holds the blocks and components we use in CitizenNet applications. These atoms can be built, styled, and rigorously tested without being forced into the context of the application. That allows for faster fixes and iteration in a sandbox environment so we can isolate errors, and more importantly, it allows easy access for business and design teams to verify our components without having to wait for a staging release or build anything locally.

This separation of concerns carries the same benefits as functional programming generally and fits well with using Tailwind (functional CSS) and PureScript. This UI repository focuses on providing self-contained, well-tested design atoms that can be dropped into any Halogen-based application and just as easily be updated or replaced. This allows the consuming application codebases to focus on providing a robust, usable application for users.

There are four relevant parts to this project:

  • src: contains the pre-built components and UI styles we can drop into application screens
  • test: contains snapshot and logic tests for our components
  • css: contains our modified version of Tailwind
  • ui-guide: contains a small PureScript site demonstrating our components and styling so we can visually test implementations
  • dist: contains the built CSS to import into Wildcat, and an index.html file usable for local testing

Use

Preview & Testing

One of the major goals of this project is to provide a minimal environment to test the UI components we build and ensure the behaviors and styling are correct without coupling them to a particular screen in the app. Once the individual units are built and tested, we know we can safely import and use them in the app.

Developing

All you need to do to get started is run:

make

This will install all dependencies and build the project. After making changes you can run the same command to build those changes. To see a list of the potentially useful commands, run:

make help

Publishing

One of the primary aims of this project is to provide a way for non-PureScript developers to view and test our components. That ability is provided by the generated documentation site. This site is automatically built by Circle CI on the gh-pages branch.

Our built CSS is version controlled, so that consuming applications can use it with minimal changes to their build system. Running make before committing will not only validate that you're checking in code that compiles, but that the CSS is up to date. However, if you forget to build before checking in your code, there is a Circle CI step that will validate that the CSS is up to date for you.

Releasing

To create a new release:

  1. Create a tag for the version.
    $ git tag $NEW_VERSION
  2. Push main and the tag to the repo.
    $ git push --tags origin main
  3. Create a release on GitHub for the tag. The description should document the changes in this new version.

purescript-ocelot's People

Contributors

arthurxavierx avatar boygao1992 avatar carolag avatar citizengabe avatar crcornwell avatar davezuch avatar dependabot[bot] avatar foresttoney avatar joneshf-cn avatar srghma avatar thomashoneyman avatar vanceism7 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  avatar  avatar  avatar  avatar  avatar  avatar

purescript-ocelot's Issues

Fix scoped CSS to work with arbitrary outer HTML, not just internal UI lib

@thomashoneyman reported on Jira:

I'm attempting to mount components (with their scoped CSS) directly into HTML that has an external stylesheet. Some of our styles now clash, like our resets specific to UI kit.

Expected behavior: I can include cn-tailwind.scoped.css in the Select documentation without it affecting any of the page styles. I can then build a typeahead using the Ocelot styles (working around the parent CSS needed).

Note: If this doesn't seem worth the effort we could just include a small custom stylesheet to write styles for the few example components we need.

Need more information from `SelectionChanged` message in typeahead

Environment

  • PureScript 0.12.0
  • Halogen ^4.0.0
  • Ocelot 0.10.2

Current behavior

Typeahead component raises SelectionChanged message whenever the selected item is modified, regardless of what or how that was triggered, and without any way for the parent to know. This can result in an inability for the parent to reason about what to do.

Consider this scenario: a used car inventory page that lets you filter by make and model. Both make and model typeaheads have handlers that update the inventory results when the user makes or clears a selection. However, the make typeahead's handler will also need to reset the model typeahead, as those models will no longer be valid. Here's where we run into a problem: imagine the user has selected the make "VW" and the model "Jetta", then they decide to switch the make to "Toyota". This triggers the handler for the make to fetch new results, but also clear out the model selection from the invalid options and "Jetta" selection. But clearing the "Jetta" is a selection change, so this will trigger the handler to unnecessarily fetch new results.

This is a simplified example, and can actually get a lot uglier. Especially when you introduce multiple sources of truth (i.e. query params + component state).

Desired behavior

If the SelectionChanged message had some way of telling the parent what triggered the selection change, the parent could make better decisions on how to react. E.g., only fetch new results when the item was changed by the user, or when it wasn't triggered from the Reset query.

Nice!

This is really nice!

Is this package registered on Bower?

I have to ask because this breaks some scripts I run.

> bower info purescript-ocelot
bower ENOTFOUND     Package purescript-ocelot not found

Please try to register this and publish it on Bower, so that I have less maintenance work in the future.

Add `receiver` to typeaheads and dropdowns

Environment

  • Ocelot [v0.14.5]

Current behavior

Currently you can set the initial items for a dropdown or typeahead via either the parent's render function, or the parent's eval by sending the child component the appropriate query. However, the only way to update the items for a dropdown or typeahead is from the parent eval via a child query.

Expected behavior

There are two scenarios for managing the items for a component:

1. letting the child fully manage them

In this scenario, the parent fetches the items once and passes them to the child, or provides the child a function for fetching them itself—as with an async typeahead. In this scenario, the parent needn't ever hold on to the items in its own state. This scenario is currently supported by Ocelot.

2. the parent manages the items

In this scenario, the parent has reason to deal with the items and hold onto them in state, and the child should be able to basically use the items that are managed on the parent state. This scenario is only partially supported, and requires manually updating the child's items.

Currently, the items on the parent's state can be passed to a dropdown like so:

HH.slot unit Dropdown.componont
  { items: state.items
  , selectedItem: state.selectedItem
  , render: renderDropdown
  }

But then when state.items changes, the dropdown component won't be notified. If we update the typeahead and dropdown components with a receiver, we can respond to changes in input from the parent.

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.