Giter VIP home page Giter VIP logo

antizer's Introduction

antizer

Antizer is a ClojureScript library implementing Ant Design React components for Reagent and Rum.

Ant Design is an enterprise-class UI design language and React-based implementation with the following features:

  • An enterprise-class UI design language for web applications.
  • A set of high-quality React components out of the box.
  • Extensive API documentation and examples.

Resources

Status

All the Ant Design components should be fully functional and production-ready. If you discover any missing or invalid components, please file a ticket.

Who's Using Antizer

Usage

To use Antizer, add the following to your project.clj:

[antizer "0.3.3"]

You would also need to add the ClojureScript React library that you will be using.

For Reagent:

[reagent "X.Y.Z"]

For Rum:

[rum "X.Y.Z"]

It is also necessary to include the relevant Ant Design CSS stylesheet in your HTML page. There are two ways that the CSS files can be included:

  1. Loading the CSS stylesheet from an external CDN:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/antd/${antd_version}/antd.min.css">

where ${antd_version} must be the same antd library version as the one that Antizer is being linked to.

  1. Alternatively, the CSS sheetsheet can be loaded from either of the following classpaths. This can be done via Ring library's wrap-resource function:
  • cljsjs/antd/development/antd.inc.css
  • cljsjs/antd/production/antd.min.inc.css

An example of how this can be done is provided by https://github.com/dfuenzalida/antizer-demo.

You can also follow the instructions for customization with LESS here.

Quick Example

For Reagent:

(require '[antizer.reagent :as ant])
(require '[reagent.core :as r])

(defn click-me []
  [ant/button {:on-click #(ant/message-info "Hello Reagent!")} "Click me"])

(defn init! []
  (r/render [click-me] (.-body js/document)))

For Rum:

(require '[antizer.rum :as ant])
(require '[rum.core :as rum])

(defn click-me []
  (ant/button {:on-click #(ant/message-info "Hello Rum!")} "Click me"))

(defn init! []
  (rum/mount (click-me) (.-body js/document)))

Examples

To compile the examples:

lein with-profile +examples cljsbuild once

To compile the examples and enable hot reloading with figwheel:

lein with-profile +examples-dev figwheel

After compilation, open up the respective HTML page in the examples/resources folder in your browser.

Changes

0.3.3

0.3.2

0.3.1

  • Updated antd library to 3.8.0.
  • Added documentation on loading CSS files. #11
  • Added Card.Meta example.
  • Fixed Form example.
  • Minor fomatting changes to docstring.

0.3.0

  • Updated antd library to 3.7.1. #16 thx @sctianwei, @piotr-yuxuan
  • Fixed autocomplete example for empty string.
  • Fixed layout issue in examples.
  • Removed known issue for DatePicker and Calendar components.
  • Added props argument to reagent.create-form. #12 thx @AndreasKlein

0.2.2

  • Updated antd library to 2.12.3.
  • Fixed resource typo in README.md and documentation. #1 thx @weavejester
  • Added missing component: Breadcrumb.Item. #2 thx @weavejester
  • Added new component: Input.TextArea. #3 thx @mbuczko
  • Fixed layout issue in examples.
  • Added note on DatePicker and Calendar known issues.

0.2.1

  • Updated antd library to 2.11.2.
  • Updated instructions for CSS file inclusion.
  • Added Avatar component and example.
  • Fixed layout and CSS styles for examples.
  • Fixed cljsbuild settings for examples.

Known Issues

None

Acknowledgement

Thanks to Ant Design, cljsjs/antd, Reagent, Rum and of course ClojureScript, without which this project would not be possible.

License

Copyright © 2017 Michael Lim

Licensed under Eclipse Public License (see LICENSE).

antizer's People

Contributors

christoph-frick avatar krzysiekj avatar priornix avatar sctianwei 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

antizer's Issues

README resource typo

"cljsjs/development/antd.inc.css" and "cljsjs/production/antd.min.inc.css" in the README should be: "cljsjs/antd/development/antd.inc.css" and "cljsjs/antd/production/antd.min.inc.css

Collapsed menus don't behave as ones in ANT's demos

The collapsed menu in ANT's demos shows large icons and no text. With antizer collapsed menu shows like this:

antizer-menu

;; modified antizer example:
,,,
       [ant/layout-sider
        {:collapsible true}
        [side-menu]]
,,,

I have also pulled the latest antd into cljsjs/ant locally but it didn't help. So I would guess it's something on antizer side. Any ideas?

Thanks!

Text cursor jumps to last position for ant/input controllable value

It works fine with html [:input], but for ant/input check this:

(defn example [_]
  (let [state (r/atom {:title ""})]
    (fn [_]
      [ant/form
       [ant/form-item
        [ant/input
         {:value       (:title @state)
          :on-change   (fn [e] (swap! state assoc :title (.. e -target -value)))
          :placeholder "Title"}]]])))

antizer-examples warnings

antizer-examples (rum-flavour) throws multiple warnings of this nature:

bundle.js:1710 Warning: Each child in an array or iterator should have a unique "key" prop. 
Check the top-level render call using <Card>. 

These warnings are suprisingly sticky. They are not switched off by adding the usual keys or rum/with-key calls e.g. to
https://github.com/priornix/antizer/blob/master/examples/src/antizer_examples/rum.cljs#L50
and
https://github.com/priornix/antizer/blob/master/examples/src/antizer_examples/rum.cljs#L52

layout-sider render twice on first load

Code to reproduce this issue:

(defn mysider []
  (prn "sider ")
  [ant/layout-sider "sider"])

(defn main-body []
  (prn "body...")
  [ant/layout
   [ant/layout-header "header"]
   [ant/layout
    [mysider]
    [ant/layout-content "content"]]])

sider will be printed twice, if I change ant/layout-sider to :div, then sider will be normal and printed only once.

I can confirm this is only for antizer for I can't reproduce this in plain JSX.

class MySider extends Component {
  render() {
    console.log('sider') 
    return <Sider>Sider</Sider>
  }
}

class App extends Component {
  render() {
    return (
      <Layout>
      <Header>Header</Header>
      <Layout>
        <MySider></MySider>
        <Content>Content</Content>
      </Layout>
      <Footer>Footer</Footer>
    </Layout>
    );
  }
}

sider will be printed just once in this snippet.

The version I test is:

                 [cljsjs/antd "3.1.0-0"]
                 [cljsjs/react "16.2.0-3"]
                 [antizer "0.2.2" :exclusions [cljsjs/antd]]
                 [reagent "0.8.0-alpha2" :exclusions [cljsjs/react]]

How to implement filterDropdown from antd's Table component?

Hello!

I'm trying to recreate antd's Table component that features a filter dropdown function in clojurescript.

image

However, looking at the React code, I have no idea how to convert it into clojurescript, more specifically on the part where we deconstruct filterDropdown into setSelectedKeys, selectedKeys, etc.

The following is the code in React:

getColumnSearchProps = dataIndex => ({
    filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
      <div style={{ padding: 8 }}>
        <Input
          ref={node => {
            this.searchInput = node;
          }}
          placeholder={`Search ${dataIndex}`}
          value={selectedKeys[0]}
          onChange={e => setSelectedKeys(e.target.value ? [e.target.value] : [])}
          onPressEnter={() => this.handleSearch(selectedKeys, confirm, dataIndex)}
          style={{ width: 188, marginBottom: 8, display: 'block' }}
        />
        <Space>
          <Button
            type="primary"
            onClick={() => this.handleSearch(selectedKeys, confirm, dataIndex)}
            icon={<SearchOutlined />}
            size="small"
            style={{ width: 90 }}
          >
            Search
          </Button>
          <Button onClick={() => this.handleReset(clearFilters)} size="small" style={{ width: 90 }}>
            Reset
          </Button>
        </Space>
      </div>
    ),
    filterIcon: filtered => <SearchOutlined style={{ color: filtered ? '#1890ff' : undefined }} />,
    onFilter: (value, record) =>
      record[dataIndex]
        ? record[dataIndex].toString().toLowerCase().includes(value.toLowerCase())
        : '',
    onFilterDropdownVisibleChange: visible => {
      if (visible) {
        setTimeout(() => this.searchInput.select(), 100);
      }
    },
    render: text =>
      this.state.searchedColumn === dataIndex ? (
        <Highlighter
          highlightStyle={{ backgroundColor: '#ffc069', padding: 0 }}
          searchWords={[this.state.searchText]}
          autoEscape
          textToHighlight={text ? text.toString() : ''}
        />
      ) : (
        text
      ),
  });

Can anybody help me? :( Any help or suggestion would be greatly appreciated!

Table scroll

How is scrolling added to an ant table?

I tried a few different things and they didn't work.
{:scroll {:x "50%"})}
{:scroll (clj->js {:x 800})}

Numbers vs string percentages didn't make a difference.

Couldn't find any examples.

Does this even work at the moment?

Accessing things like Card.Meta

How to translate examples like this from antd docs? See https://ant.design/components/card/

  <Card
    style={{ width: 300 }}
    cover={<img alt="example" src="https://gw.alipayobjects.com/zos/rmsportal/JiqGstEfoWAOHiTxclqi.png" />}
    actions={[<Icon type="setting" />, <Icon type="edit" />, <Icon type="ellipsis" />]}
  >
    <Meta
      avatar={<Avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />}
      title="Card title"
      description="This is the description"
    />

Question regarding adapt-class implementation

I was trying to get the following snippet to work in RUM,

(def menu-items [{:key "home"
                  :title "Home"
                  :icon "smile"}
                 {:key "about-us"
                  :title "About Us"
                  :icon "smile"}])

(defn menu []
  (ant/menu
   {:theme "dark" :mode "inline" }
   (for [{key :key title :title icon :icon} menu-items]
     (ant/menu-item
      {:key key}
      (ant/icon {:type icon})
      [:span.nav-text title]))))

But, it was not showing up. Digged a bit into the implementation of adapt-class and found this,

...
type# (first children)

new-children (if (sequential? type#)
                       [(sablono.interpreter/interpret children)]
                       children)

vector->react-elems (fn [[key val]]
                              (if (sequential? val)
                                [key (sablono.interpreter/interpret val)]
                                [key val]))
...

So, I went ahead changed that to the following and everything started working fine(at least for me 😄 )

...
new-children (sablono.interpreter/interpret children) 

vector->react-elems (fn [[key val]]
                                      [key (sablono.interpreter/interpret val)])
...

I think sablono already handles all the cases were input being vector, seq, object etc.. So, this is sufficient for the functionality right?

Add support for Fulcro

Fulcro seems to be becoming the successor to om-next. Just a quick poll, to see who might be interested in this? I don't time to work on this in the near future, so if anyone is keen to do a port, let us consolidate the discussion here.

Example needed: Form Create inside Modal

I'm finding it tricky to understand what is necessary to duplicate https://ant.design/components/form/#components-form-demo-form-in-modal using Antizer's create-form approach.

The tricky part is to find a way to bind the modal OK and Cancel click events so they behave as form buttons and trigger validation correctly. The Ant example accomplishes this using form.refs after using Form.Create to create a modal wrapping a form. It's not clear that Antizer's create-form can handle this wrapped form creation. It's documentation says that form.create 'Calls Form.create() decorator with the form to be created. form can be any hiccup form.'.

I'd love there to be a Form inside Modal example :)

I'm using Rum.

cljsjs/antd pulls in the whole of antd

Do let me know If there's a more appropriate channel to discuss user issues.

I'm starting from a leiningen project with the following dependencies:

  :dependencies [[org.clojure/clojure "1.9.0-alpha16"]
                 [org.clojure/clojurescript "1.9.908"]
                 [antizer "0.2.2"]
                 [rum "0.10.8"]
                 [cljs-css-modules "0.2.1"]
                 [cljsjs/antd "2.12.3-0"]
                 [cljsjs/moment "2.17.1-1"]
                 [figwheel-sidecar "0.5.13"]]

which provokes the startup warning:

antd.inc.js:sourcemap:45118 You are using a whole package of antd, please use https://www.npmjs.com/package/babel-plugin-import to reduce app bundle size.

Does this mean that it would be better to avoid using cljsjs/antd and somehow build antd using webpack and babel-plugin-import? If so, perhaps some documentation on this would be useful.

Table dataSource not being camel cased automatically

If I do something like

[ant/table {:data-source [..]}

it doesn't work, while [ant/table {:dataSource [...]}] works as expected.
Checking the code it looks like it should work really

(ac/map-keys->camel-case {:data-source "hello"})
{"dataSource" "hello"}```

Any idea about what could be the issue?

How to uncheck a Radio Button?

I could not find a way to uncheck radio buttons? Could you provide some examples?

[ant/radio
          {:value "today" :checked @checked?} ;; does not re-render if it's false
          "Today"]

Support rum from v0.12.0

Hello,

From Rum v0.12.0 release notes

Breaking
...
Replaced Sablono with Daiquiri, reworked Sablono fork (in case if you are depending on Sablono)

Is antizer going to support the new Rum version?
Maybe does some fork which is already support it exist?

Thanks.

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.