- 
                Notifications
    You must be signed in to change notification settings 
- Fork 33
Normalizing it as base tailwindcss #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Removed extra spacing values. Using only what is used in base tailwindcss. Migrate Padding and Margin variants to match base tailwindcss. px-10 should be traslated to px10 rather than pX10. THIS IS NOT BACKWARDS COMPATIBLE.
| Hi, @TVke can get comments on this PR. | 
Added some tests for generators (more should be added) FIXED cache issue in converter Updated index.d.ts for generator (Not updated type declarations fully) Updated docs to match padding and spacing
| Worked to be done
 | 
Improved caching in converter
| Made  | 
| thank you for the hard work. I want to take the time to thoroughly check everything but for now it looks really nice. Greetings | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am waiting to merge this as there are some task to be done.
You commented:
Work to be done
  - Updating type declaration
  - More examples in the readme for converter
  - Adding more tests for converter
Corrected configure method
| 🧐 Hmmm... You need custom configsimport { Tailwind } from 'react-native-tailwindcss/tailwind';
const tailwind = new Tailwind(yourCustomConfig);
const t = tailwind.style;
<View style={[t.absolute, t.inset0, t.p4, t.bgBlue500, t._mx2, t.w1_2]} />
// OR
const c = tailwind.converter;
<View style={c('absolute inset-0 p-4 bg-blue-500 -mx-2 w-1/2')} />Using in Hooksimport {View} from 'react-native';
import {useDarkMode} from 'react-native-dynamic'
import { Tailwind } from 'react-native-tailwindcss/tailwind';
const useTailwindCss = () => {
    const isDarkMode = useDarkMode();
    const tailwind = new Tailwind({
        theme: {
            extend: {
                colors: {
                    primary: isDarkMode? '#FFFFFF' : '#000000'
                }
            }
        }
    });
    
    return tailwind.converter;
};
const MyComponent = () => {
    const c = useTailwindCss();
    
    return <View style={c('absolute inset-0 p-4 bg-blue-500 -mx-2 w-1/2')} />
};NOTE: All other things remains sameExcept: 
 | 
| This PR is getting larger but is now a step more towards actual tailwind's documentation. I have added plugin support too. Plugin support is documented here https://tailwindcss.com/docs/plugins/#app. I suggest to merge this and then help me with issues. One major issue is with updating types which I completely fail too. I have worked with typescript but I am not able to add custom '.d.ts' file type. I will surely mention all issue and things there is lacking. | 
| I partially resolved #18 . Support for custom configuration is now added too. But type generator tools remain undone. | 
Made generator functional based
Added check for empty classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good I just want a little more explanation with some parts 😊
|  | ||
| test('alignContent', () => { | ||
| expect(alignContent).toEqual(require('./fixtures/outputs/tailwind/alignContent')); | ||
| expect(alignContent({theme, colors})).toEqual(require('./fixtures/outputs/tailwind/alignContent')); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alignContent does not need colors or am I missing something 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually to save time I passed theme and colors in all closures, because there were lot of closures. I used the fact that javascript will discard any arguments passed if it is not in use and will not give error or warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that it easier to just pass them all but I think it is way cleaner to think about what it needs so I would love this to be only the necessary parameters.
I will do this if you don't find the time.
greetings
Thomas
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do this.
| @Faisal-Manzer greetings | 
| At some point of time you will release  Also, now  | 
| This is cool! I want to take a deeper look at the plugin capability, especially. The ability to do runtime changes (like for dark mode) is interesting, but it seems like it might overstep tailwindcss' responsibilities? Don't think the web version has that.. Not sure it belongs in this lib. <View style={[t.bgPrimary, t.dark(t.bgGrey100)]} />I like the capitalization changes, too, but tailwind is very careful with deprecations & breaking changes. Wonder if there's a way we can include both with deprecation warnings on the old syntax. | 
Normalizing it as base tailwindcss
TERMS:
THIS IS NOT A BACKWARDS COMPATIBLE PR
Issues
The main issue solved:
This is a great package with a great API interface. But it goes somewhere in some different paths with base.
height,width,maxHeight,minHeight,maxWidth,minWidth: These were having many intermediate values which are not in base. Issue Types for custom configs // Tailwind philosophy #18 talks about it too.padding,margin: Understating with example. Currentlypx-10is been converted topX10which should actually be converted topx10simply.The basic idea should be I someone reads tailwindcss documentation, he/she should good without looking deep into react-native-tailwindcss documentation
Fixes
As mentioned above the issues have been resolved. Ther are only spacing values which are present in the base. Now padding and margin are translating as referred above. i.e.
px-10topx10and so on...Additions
As this PR makes it somewhere even with the base. I also added a functional utility
converter. (defined in utils/converter.js).The util is a function which can be used as
Issues with this PR
I will try to solve this issue later.
Apology
I know package maintainers do very hard work of creating a great package and someone comes and try to do things in their own way. There is much thought in maintainers about how this should move.
Also so I needed these change immediately so I published my version (at https://github.com/Faisal-Manzer/react-native-tailwindcss/packages/289166). I will delete my version as soon as this PR gets merged.
I am very hopeful for this package.