Skip to content
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

Purge function will conflict with getColor #96

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ const create = tailwindStyles => {
return useVariables(style);
};

// Pass the name of a color (e.g. "blue-500") and receive a color value (e.g. "#4399e1"),
// or a color and opacity (e.g. "black opacity-50") and get a color with opacity (e.g. "rgba(0,0,0,0.5)")
// Pass the name of a color (e.g. "bg-blue-500") and receive a color value (e.g. "#4399e1"),
// or a color and opacity (e.g. "bg-black bg-opacity-50") and get a color with opacity (e.g. "rgba(0,0,0,0.5)")
const getColor = name => {
const style = tailwind(name.split(' ').map(className => `bg-${className}`).join(' '));
const style = tailwind(name);
return style.backgroundColor;
};

Expand Down
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Get color value from Tailwind CSS color name.
```js
import {getColor} from 'tailwind-rn';

getColor('blue-500');
getColor('bg-blue-500');
//=> '#ebf8ff'
```

Expand All @@ -204,7 +204,7 @@ To get a color with opacity:
```js
import {getColor} from 'tailwind-rn';

getColor('blue-500 opacity-50');
getColor('bg-blue-500 bg-opacity-50');
//=> 'rgba(66, 153, 225, 0.5)'
```

Expand Down
4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ test('ignore non-string values when transforming CSS variables', t => {
});

test('get color value', t => {
t.is(getColor('blue-500'), 'rgba(59, 130, 246, 1)');
t.is(getColor('bg-blue-500'), 'rgba(59, 130, 246, 1)');
});

test('get color with opacity value', t => {
t.is(getColor('blue-500 opacity-50'), 'rgba(59, 130, 246, 0.5)');
t.is(getColor('bg-blue-500 bg-opacity-50'), 'rgba(59, 130, 246, 0.5)');
});

test('ignore no value param', t => {
Expand Down