项目作者: Maxihost

项目描述 :
An opinionated React & TailwindCSS-based UI kit.
高级语言: JavaScript
项目地址: git://github.com/Maxihost/metal-ui.git
创建时间: 2020-04-17T13:36:14Z
项目社区:https://github.com/Maxihost/metal-ui

开源协议:

下载


Metal UI

Metal UI is now in maintenance mode. This means we might continue to post minor updates to the project. However, we won’t be developing any new features.

Metal UI is a set of UI Components using React and TailwindCSS built by the Latitude.sh team.

Metal UI is opinionated, in the sense that it explicitly replaces TailwindCSS variants to support Latitude.sh’s brand identity. While there are no support or plan on supporting theming, most components allow for some degree of customization.

In order to use the package you need to have Tailwind installed in your project, as Metal UI doesn’t export Tailwind styles. Some components make use of twin.macro and we’re slowly transitioning the code base to use twin.macro for all components so Tailwind dependency can be dropped on projects using Metal UI. You will also need to have the GlobalStyles component set up in your app.

We built this for desktop applications, so most components are not optimized for responsiveness.

Installing

Install package:

npm install @maxihost/metal-ui

Set up

  1. Metal UI exports a Tailwind preset. This is the easiest way to get started with Metal UI. Not importing the preset will cause components that are using custom variants to break in your project.

Here’s an example of the tailwind.config.js file on a NextJS project.

  1. module.exports = {
  2. presets: [require("@maxihost/metal-ui/tailwind-preset")], {/* preset */}
  3. purge: [
  4. "./pages/**/*.{js,jsx,ts,tsx}", {/* change these to your own project paths */}
  5. "./components/**/*.{js,jsx,ts,tsx}",
  6. "./node_modules/@maxihost/metal-ui/dist/**/*.{js,jsx,ts,tsx}",
  7. "./next.config.js",
  8. ],
  9. variants: {},
  10. };
  1. Metal UI sets Inter as the default font, but it doesn’t export the font in order to keep the package small for users that don’t use Inter. If you do use Inter, all you have to do is import the font in your project.

On a NextJS project, this is as simples as extending the Head component on _document.js

  1. import Document, { Html, Head, Main } from "next/document";
  2. class AppDocument extends Document {
  3. render() {
  4. return (
  5. <Html>
  6. <Head>
  7. <link
  8. href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap"
  9. rel="stylesheet"
  10. />
  11. </Head>
  12. <body>
  13. <Main ></Main>
  14. </body>
  15. </Html>
  16. );
  17. }
  18. }
  19. export default AppDocument;
  1. Metal UI needs GlobalStyles to be set up.
  1. import { GlobalStyles } from "@maxihost/metal-ui";
  2. function MyApp() {
  3. return (
  4. <>
  5. <GlobalStyles ></GlobalStyles>
  6. <App ></App>
  7. </>
  8. );
  9. }
  10. export default AppDocument;

Example usage

Import the component:

import { Button } from '@maxihost/metal-ui';

Component Storybook

Developing

Install and run:

yarn && yarn dev

A Storybook tab will open automatically in your browser.

If you want to develop a new component or make changes to one, you might want to run it on a separate project. Go to the directory where you have Metal UI installed and run:

  1. cd PATH_TO_METALUI
  2. yarn link
  3. yarn install
  4. cd node_modules/react
  5. yarn link
  6. cd ../../node_modules/react-dom
  7. yarn link
  8. cd YOUR_PROJECT
  9. yarn link @maxihost/metal-ui
  10. yarn link react
  11. yarn link react-dom