0.0.71 • Published 14 days ago

@smwb/summer-ui v0.0.71

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days ago

Summer UI

Summer UI is full typescript library with proto-type supporting and based on material guideline

license

Installation

Summer UI is available as an npm package.

Components demo is available here & Nightly builds ;)

npm:

npm install @smwb/summer-ui

yarn:

yarn add @smwb/summer-ui

Getting started with Summer UI

Here is an example of a basic app using Summer UI's Button component:

import * as React from "react";
import "@smwb/summer-ui/styles/normalize.css";
import "@smwb/summer-ui/styles/css/summer-ui.css";
import { Button } from "@smwb/summer-ui";

function App() {
  return <Button>Hello World</Button>;
}

Full library

If you want to use full library you would import components from project root

import { Button } from "@smwb/summer-ui";

Only component

If you need minify your project you can import just several components from direct path

import Button from "@smwb/summer-ui/dist/components/button/button";

Styles

Dark & Light themes

For build-in dark&light themes use the useTheme hook. This hook returns the current theme and a callback for changing the theme:

import "@smwb/summer-ui/styles/normalize.css";
import "@smwb/summer-ui/styles/css/summer-ui.css";
import { Button } from "@smwb/summer-ui";
import { useTheme } from "@smwb/summer-ui";

function App() {
  const { theme, setTheme } = useTheme();

  return <Button onClick={() => setTheme("dark")} />;
}

Default CSS

import "@smwb/summer-ui/styles/normalize.css";
import "@smwb/summer-ui/styles/css/summer-ui.css";

Custom CSS

Using one of built-in themes
  • theme list node_modules/@smwb/summer-ui/styles/less/themes
  • copy node_modules/@smwb/summer-ui/theme.config.example to the project root and rename to theme.config
  • add script to package.json "less": "lessc -rp=/ ./node_modules/@smwb/summer-ui/styles/less/components.less src/css/summer-ui.css"
  • execute npm run less
  • import css in the project root
import "./css/summer-ui.css";
Using own theme
  • copy file node_modules/@smwb/summer-ui/styles/less/variables.less to folder /src/css/custom
  • copy file node_modules/@smwb/summer-ui/theme.config.example to the project root
    • rename theme.config.example to theme.config
    • edit theme.config @theme to @theme: "custom"
    • edit theme.config @themesFolder to @themesFolder : "/src/css";
  • edit custom.variables.less
  • add script to package.json "less": "lessc -rp=/ ./node_modules/@smwb/summer-ui/styles/less/components.less src/css/summer-ui.css"
  • execute npm run less
  • import css in the project root
import "./css/summer-ui.css";

Integrations

react-final-form

Form demo is available here

Installation:

npm install --save final-form react-final-form
import { Form } from "react-final-form";
import { TextField } from "@smwb/summer-ui/connects/rff";
import { Button } from "@smwb/summer-ui";

interface IForm {
  name: string;
  email: string;
}

const MyForm = () => {
  const onSubmit = (values: IForm) => {
    console.log(values);
  };

  const initialValues: Partial<IForm> = {
    name: "",
    email: "",
  };

  const required = (value: string) => (value ? undefined : "Required Field");

  return (
    <Form
      initialValues={initialValues}
      onSubmit={onSubmit}
      render={({ handleSubmit, values, submitting }) => {
        return (
          <form style={{ display: "flex", gap: "20px", flexDirection: "column" }} onSubmit={handleSubmit}>
            <TextField placeholder="Name" validate={required} name="name" label="Name" />
            <TextField placeholder="Email" validate={required} name="email" type="email" label="Email" />

            <Button type="submit" disabled={submitting}>
              Submit Form
            </Button>
          </form>
        );
      }}
    />
  );
};

react-table

Table demo is available here

Installation:

npm install react-table --save
import { Column, useTable } from "react-table";
import { Table } from "@smwb/summer-ui/connects/rt";

type Item = {
  name: string;
  lastName: string;
  age: number;
};

const columns: ColumnDef<Item>[] = [
  {
    header: "Name",
    cell: (row) => row.renderValue(),
    accessorKey: "name",
  },
  {
    header: "Age",
    cell: (row) => row.renderValue(),
    accessorKey: "age",
  },
  {
    header: "Last Name",
    cell: (row) => row.renderValue(),
    accessorKey: "lastName",
  },
];

const data: Item[] = [
  { name: "First", age: 20, lastName: "Dach" },
  { name: "Alex", age: 10, lastName: "Fax" },
  { name: "John", age: 35, lastName: "Doe" },
  { name: "Bax", age: 30, lastName: "Heller" },
  { name: "Second", age: 47, lastName: "Name" },
  { name: "Abc", age: 14, lastName: "Def" },
];

export const Table = () => {

  return (
    <Table columns={columns} data={data} />;
  );
};
0.0.71

14 days ago

0.0.70

18 days ago

0.0.66

5 months ago

0.0.67

5 months ago

0.0.68

4 months ago

0.0.69

4 months ago

0.0.65

6 months ago

0.0.63

7 months ago

0.0.64

7 months ago

0.0.62

7 months ago

0.0.61

7 months ago

0.0.47

1 year ago

0.0.60

1 year ago

0.0.59

1 year ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.53

1 year ago

0.0.54

1 year ago

0.0.55

1 year ago

0.0.56

1 year ago

0.0.57

1 year ago

0.0.58

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.37

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago