GithubHelp home page GithubHelp logo

moaijs / moai Goto Github PK

View Code? Open in Web Editor NEW
126.0 7.0 25.0 6.4 MB

A React component library, where buttons look like buttons🗿

Home Page: https://moaijs.com

License: MIT License

JavaScript 1.61% TypeScript 81.79% CSS 16.60%
react components-library

moai's Introduction

Heads up! This project is no longer in active development. It will be archived soon. Some suggestions:

  • Build your own UI kit with a good foundation like Radix or Headless UI. This is what I'm actually doing these days myself.
  • Fork this project. You have my sword, and bow, and axe, and only 22 unresolved bugs.
  • Refactor Moai to utilise Radix (which is what I wanted to do, if I don't need to pay the bills)

Moai UI Kit 🗿

A React Component Library, Where Buttons Look Like Buttons.

Moai preview

Contributing

Get in touch

moai's People

Contributors

clitetailor avatar dangbt avatar dependabot[bot] avatar devminh avatar huyng12 avatar ldakhoa avatar lqt93 avatar monodyle avatar ngocnhi123 avatar nguyenhuedang avatar nhducit avatar nvh95 avatar rovn208 avatar thien-do avatar tuhuynh27 avatar violeine avatar zerox-dg 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

moai's Issues

Consistent font between OS

Currently the text rendered in Mac is bolder than in Linux. Should use font smoothing anti-aliased to have them consistent.

Allow Table to have fixed column at last position

Some tables have an Action column which contains main control to interact with row data (usually Edit, Delete, or View Detail). With the current option, it’s not suitable to fixed that column at the first position.

[Table] Allow rowKey to use index as key

There are cases where "index" is the most appropriate key. For example, the list of passengers in a booking. We don't deal with each passenger individually but only render them as a list.


Implementation note: basically we'd need:

mono font

    /* AVOID Ubuntu Mono as it's significantly smaller than others at the
	same font size */
    --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
        "Courier New", monospace;

Remove declaration bundling

Previously we think that bundling/merging TypeScript's declaration files (d.ts) is pretty cool because it makes the published content looks pretty clean (< 10 files). However, the process turns out to be quite complicated with even having some hacks (e.g. the "removing css imports") to make it works. It's just not worth it.

It's better to not bundling at the moment and wait for official support: microsoft/TypeScript#4433

useTheme

like this but with favicon

export const useTheme = (): [Theme, SetTheme] => {
    const state = useStorage("pref-theme", "theme-auto");

    const [theme] = state;
    React.useEffect(() => {
        html.classList.add(theme);
        return () => html.classList.remove(theme);
    }, [theme]);

    return state;
};

Distribute from root

Traditionally a lib is built from "src" to "dist", then the whole project is published to npm. This means to use something via an absolute path we would do import {} from "@moai/core/dist/something".

Previously, we think this is quite ugly and we do a little trick that we move the package.json to inside "dist" and then publish only the "dist" folder (as a whole project). This means the import above would now be nicer as @moai/core/something.

However, this yields more problems than benefits:

  1. Is that we sym-link just won't work anymore. Yes we can sym-link to the dist folder itself, but most build will just delete the dist and create a new one instead of emptying its content.
  2. Versioning is more difficult. We need to increase the version before the build because the "moving package.json" is a part of the build.

In conclusion, we should just rollback and publish from root

Support shared list in Input

Currently if using list then each Input will create its own List. There should be a way to specify an id so that multiple Input will use 1 list

Enforce button height using height

Instead of padding + line height + border. Why? To keep the same height between different styles (some have border and some don't)

Also it should fix the height issue of MenuButton, which uses Button.styles to have faked button appearance

Support button group

Basically Switcher should be implemented as a set of Buttons

Also it should be possible to group a Button and a MenuButton

Support input counter

  • Displays the maximum number of characters per user input.
    image
  • Value <= maximum number of characters.

Add DatePicker component

The current has a blocking issue that its representational format is not customizable but always follow browser's locale format. This is pretty bad because for example most computers in Vietnam uses en-us language but users do expect to see (and input) as dd/mm/yyyy

Support flat button + highlight

Currently we are banning the use of style={Button.styles.flat} and highlight={true} at the same time:

[
(p) => p.style === Button.styles.flat && p.highlight === true,
"Flat buttons can not have highlight style",
],

As we can see this is only a "soft" ban, which means we throw a run-time error to prevent the users from using them, without any technical limitation. In fact, previously we avoid this only because we haven't sure what should it look like. Now we have.


To start with this issue, first see that the "style" prop of Button is not a string, but an object. This allows Moai's themes can extend and modify the styles properly. However, it's pretty simple, a ButtonStyle is simply a group of classes to be applied to the button tag under different situations:

export interface ButtonStyle {
main: string;
selected: string;
highlight: string;
busy: string;
}

And there are 2 pre-defined styles: "outset" and "flat":

Button.styles = {
outset: {
main: [border.radius, outset.main].join(" "),
selected: outset.selected,
highlight: outset.highlight,
busy: outset.busy,
} as ButtonStyle,
flat: {
main: [flat.main].join(" "),
selected: flat.selected,
highlight: "",
busy: flat.busy,
} as ButtonStyle,
};

Which come from these 2 CSS Module files:

import flat from "./flat.module.css";
import outset from "./outset.module.css";

Notice that the "flat" style does not have a class for "highlight" field. Meanwhile, the "outset" style does, which is why outset buttons have highlight style, but flat button does not.

Our job here is to define the "highlight" CSS for the "flat" style, which should be coded inside "flat.module.css", and referenced at Button.styles.flat.highlight (replace the empty string).

The CSS is simple, it should set the button text to our primary color, something like this:

:global(.light) .highlight {
	color: var(--highlight-7);
}
:global(.dark) .highlight {
	color: var(--highlight-5);
}

To test your work, just run the storybook locally (yarn storybook), and look for the Button story, then set "style" to "flat" and "highlight" to "true". If it shows a blue text, you should PR!

Table row with compact height

The current height of each row feels too large for an Enterprise app. We should have a size option which controls table row height.

interface TableProps {
  size: "dense" | "normal" | "loose" // Maybe T-shirt sizes
}

Build(icon): Simplify icon build

Currently the build setup of core is much better than icon:

  • Use yarn instead of NPM
  • Publish the package, not package/dist
  • No need for sh scripts

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.