Coder Social home page Coder Social logo

valentinndimitroff / ra-compact-ui Goto Github PK

View Code? Open in Web Editor NEW
91.0 4.0 20.0 1.38 MB

Enhanced components for popular framework react-admin. Helps reducing the styling boilerplate code and eases layout customizations.

License: MIT License

JavaScript 100.00%
react-admin material-ui reactjs styling

ra-compact-ui's People

Contributors

jfm-its avatar jtomaszewski avatar luigimorel avatar notz avatar trodery avatar valentinndimitroff 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

Watchers

 avatar  avatar  avatar  avatar

ra-compact-ui's Issues

Example of working code

Hi,
I really like the work you made, but it's difficult to understand how to use this package.
If you could provide an example of code I would really appreciate.

Thanks

Custom Fields using Controller Props are not working in BoxedShowLayout

<ShowController {...props} component="div">
        {(controllerProps) => 
            <ShowView {...props} actions={<TaskShowActions />} {...controllerProps}>
                <BoxedShowLayout>
                  <RaBox display="flex">
                    <RaBox
                      display="flex"
                      flexWrap="wrap"
                      flexGrow={4}
                      className={classes.detailsBox}
                    >
                      <RaBox
                        flex="0 0 100%"
                        display="flex"
                        justifyContent="space-between"
                      >
                        <TextField label="Task Id" source="taskId" />
                        <TextField
                          label="Task Type"
                          source="taskTypeDisplayName"
                        />
                        {controllerProps.record &&
                          controllerProps.record.taskType ===
                            "order_management_task" && (
                            <TextField
                              label="Customer Name"
                              source="customerName"
                            />
                          )}
                        {controllerProps.record &&
                          controllerProps.record.taskType ===
                            "order_management_task" && (
                            <TextField label="Phone Number" source="phone" />
                          )}
                      </RaBox>
                    </RaBox>
                  </RaBox>
                </BoxedShowLayout>
            </ShowView>
        }
      </ShowController>

TypeError: Cannot read property 'source' of undefined

CompactForm throws error in production when child is a function

I have the following piece of code, aligned to a material ui stepper which works perfectly in Development.

                <CompactForm layoutComponents={[RaBox]} toolbar={buttons()} {...props}>
                    <FormDataConsumer>
                        {({ formData, ...rest }) => getStepContent(activeStep, formData)}
                    </FormDataConsumer>
                </CompactForm>

However when I move it to production I get an error thrown in CompactFormView at this point variant={x.props.variant || variant} because x.props isnt a thing for the child function.

Feature Request: replacement tab component

Hi

It would be nice to have a component to replace the Original React-Admin Tab component so that we could render custom layouts within

Currently the labels of fields do not show up as the Original Component has no knowledge of the custom layouts

React does not recognize the `basePath`

I get the following error when I use boxedshowlayout:

react-dom.development.js:86 Warning: React does not recognize the basePath prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase basepath instead. If you accidentally passed it from a parent component, remove it from the DOM element.
at span
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at Grid2 (http://localhost:5173/node_modules/.vite/deps/chunk-6O75EDD4.js?v=9e94d845:6636:24)
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at Labeled (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:168436:27)
at div
at RaField (http://localhost:5173/node_modules/.vite/deps/ra-compact-ui.js?v=9e94d845:243:9)
at div
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at Grid2 (http://localhost:5173/node_modules/.vite/deps/chunk-46XUJWJX.js?v=9e94d845:425:26)
at RaGrid (http://localhost:5173/node_modules/.vite/deps/ra-compact-ui.js?v=9e94d845:584:9)
at div
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at CardContent2 (http://localhost:5173/node_modules/.vite/deps/chunk-FQCDPE3U.js?v=9e94d845:6147:21)
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at CardContentInner (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:2767:29)
at CompactShowLayout (http://localhost:5173/node_modules/.vite/deps/ra-compact-ui.js?v=9e94d845:457:9)
at GridShowLayout
at span
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at Grid2 (http://localhost:5173/node_modules/.vite/deps/chunk-6O75EDD4.js?v=9e94d845:6636:24)
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at Labeled (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:168436:27)
at div
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at Grid2 (http://localhost:5173/node_modules/.vite/deps/chunk-6O75EDD4.js?v=9e94d845:6636:24)
at Tab (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:182918:27)
at RenderedRoute (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3429:5)
at Outlet (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3728:26)
at div
at RenderedRoute (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3429:5)
at Routes (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3788:5)
at div
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at OptionalRecordContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:11138:22)
at TabbedShowLayout (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:182999:28)
at div
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at Paper2 (http://localhost:5173/node_modules/.vite/deps/chunk-ETJAFPX2.js?v=9e94d845:124:21)
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at Card2 (http://localhost:5173/node_modules/.vite/deps/chunk-FQCDPE3U.js?v=9e94d845:5755:21)
at div
at div
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at ShowView (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:179666:27)
at RecordContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:10625:25)
at ShowContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:16447:25)
at ShowBase (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:16478:25)
at Show (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:179751:21)
at JobSeekerShow (http://localhost:5173/src/resources/JobSeeker/JobSeekerShow?import:104:26)
at RenderedRoute (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3429:5)
at Routes (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3788:5)
at ResourceContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:19227:25)
at Resource (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:19243:26)
at RenderedRoute (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3429:5)
at Routes (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3788:5)
at Suspense
at ErrorBoundary2 (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:4405:39)
at div
at main
at div
at div
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at Layout (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:4877:24)
at MyLayout
at div
at RenderedRoute (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3429:5)
at Routes (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3788:5)
at CoreAdminRoutes (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:18879:7)
at RenderedRoute (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3429:5)
at Routes (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3788:5)
at CoreAdminUI (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:18953:22)
at div
at http://localhost:5173/node_modules/.vite/deps/chunk-SIYINNXL.js?v=9e94d845:740:49
at ScopedCssBaseline2 (http://localhost:5173/node_modules/.vite/deps/chunk-FQCDPE3U.js?v=9e94d845:13659:21)
at AdminUI (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:184371:22)
at ThemeProvider (http://localhost:5173/node_modules/.vite/deps/chunk-6O75EDD4.js?v=9e94d845:4812:5)
at ThemeProvider2 (http://localhost:5173/node_modules/.vite/deps/chunk-6O75EDD4.js?v=9e94d845:4899:5)
at ThemeProvider (http://localhost:5173/node_modules/.vite/deps/chunk-DPJHASPB.js?v=9e94d845:303:12)
at ThemeProvider2 (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:1682:27)
at ResourceDefinitionContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:18474:19)
at NotificationContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:5476:25)
at I18nContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:5601:19)
at DummyRouter (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:6721:25)
at BasenameContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:6694:25)
at AdminRouter (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:6711:24)
at QueryClientProvider2 (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:2844:25)
at PreferencesEditorContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:18385:25)
at StoreContextProvider (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:4423:22)
at CoreAdminContext (http://localhost:5173/node_modules/.vite/deps/chunk-44TGPRAS.js?v=9e94d845:18517:32)
at AdminContext (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:184414:25)
at Admin (http://localhost:5173/node_modules/.vite/deps/chunk-GH4ERXBK.js?v=9e94d845:184677:32)
at SiteAdmin
at RenderedRoute (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3429:5)
at Routes (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3788:5)
at Router (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:3735:15)
at BrowserRouter (http://localhost:5173/node_modules/.vite/deps/chunk-BYM7LI66.js?v=9e94d845:4511:5)
at App
printWarning @ react-dom.development.js:86
error @ react-dom.development.js:60
validateProperty$1 @ react-dom.development.js:3757
warnUnknownProperties @ react-dom.development.js:3803
validateProperties$2 @ react-dom.development.js:3827
validatePropertiesInDevelopment @ react-dom.development.js:9541
setInitialProperties @ react-dom.development.js:9830
finalizeInitialChildren @ react-dom.development.js:10950
completeWork @ react-dom.development.js:22193
completeUnitOfWork @ react-dom.development.js:26596
performUnitOfWork @ react-dom.development.js:26568
workLoopSync @ react-dom.development.js:26466
renderRootSync @ react-dom.development.js:26434
performConcurrentWorkOnRoot @ react-dom.development.js:25738
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533
Show 17 more frames

Missing `key` parameter?

When using code like this:

<CompactShowLayout layoutComponents={[DetailCard]}>
    <DetailCard>
      <TextField label="Street Name" source="address.streetName" />
      <TextField label="Suburb or Town" source="address.suburb" />
    </DetailCard>
</CompactShowLayout>

We get following error:

Warning: Each child in a list should have a unique "key" prop.

Check the render method of `DetailCard`. It was passed a child from CompactShowLayout. See https://fb.me/react-warning-keys for more information.
    in RaField (created by CompactShowLayout)

Looking by react tree, seems like key is not passed to RaField when a field is wrapped in it? Maybe this line https://github.com/ValentinnDimitroff/ra-compact-ui/blob/master/src/details/CompactShowLayout.jsx#L39 should accept and pass over the props from https://github.com/ValentinnDimitroff/ra-compact-ui/blob/master/src/core/recursiveMethods.js#L38, or at least the props.key .

image

BoxedShowLayout doesn't work

Hi,

Really nice work but when I try to use the BoxedShowLayout with RaBox nothing happens. Maybe I did something wrong. On the other hand the grid works perfectly.

import React from "react";
import { Show, TabbedShowLayout, Tab, TextField } from "react-admin";
import { GridShowLayout, RaGrid, BoxedShowLayout, RaBox } from "ra-compact-ui";

export default function TestRunShow(props) {
  return (
    <div>
      <Show {...props}>
        <TabbedShowLayout>
          <Tab label="Summary">
            <BoxedShowLayout className="boxedShowLayout">
              <RaBox display="flex">
                <RaBox display="flex" justifyContent="space-between">
                  <TextField source="status" />
                  <TextField source="reference" />
                </RaBox>
              </RaBox>
            </BoxedShowLayout>
            <GridShowLayout className="gridShowLayout">
              <RaGrid container direction="row">
                <RaGrid item xs>
                  <TextField source="status" />
                </RaGrid>
                <RaGrid item xs>
                  <TextField source="reference" />
                </RaGrid>
              </RaGrid>
            </GridShowLayout>
          </Tab>
        </TabbedShowLayout>
      </Show>
    </div>
  );
}

Capture d’écran 2021-01-29 à 13 52 35

Any idea ?

Console Log in CompactShowLayout.js

clg

Getting a log in the console from CompactShowLayout.js line number 62

Code causing console log
console.log('recursion', { index: index, props: props, child: child });

withStyles_default is not defined

Once I've added your example to latest version of react-admin (3.14.5) it fails with a runtime error withStyles_default is not defined. Any idea what's wrong?

Warning: Each child in a list should have a unique "key" prop.

Hey, awesome layout for react-admin!

Recently I found an issue with multiple fields in single RaBox component.

Example:

<RaBox flexGrow={4} display='flex' flexDirection='column'>
  <TextField source='title' />
  <TextField source='subtitle' />
</RaBox>

The code above produces following error in console:

Warning: Each child in a list should have a unique "key" prop.

Check the render method of `Styled(MuiBox)`. It was passed a child from CompactShowLayout. See https://reactjs.org/link/warning-keys for more information.

But if it is a single field in each RaBox, no warnings.

Example:

<RaBox flexGrow={4} display='flex' flexDirection='column'>
  <RaBox>
    <TextField source='title' />
  </RaBox>
  <RaBox>
    <TextField source='subtitle' />
  </RaBox>
</RaBox>

It would be amazing if this minor issue can be fixed.

Thanks!

Support for react ^17?

Will this be updated for use with React 17?

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR!   peer react@"^16.8.0 || ^17.0.0" from @material-ui/[email protected]
npm ERR!   node_modules/@material-ui/core
npm ERR!     @material-ui/core@"^4.11.0" from the root project
npm ERR!     peer @material-ui/core@"^4.x" from [email protected]
npm ERR!     node_modules/ra-compact-ui
npm ERR!       ra-compact-ui@"*" from the root project
npm ERR!   1 more (react-dom)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.x" from [email protected]
npm ERR! node_modules/ra-compact-ui
npm ERR!   ra-compact-ui@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

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.