forked from morfeojs/morfeo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: web styled-components package introduced
- Loading branch information
Showing
23 changed files
with
343 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { parsers, theme } from '../src'; | ||
import { shadowOffset } from '../src/parsers'; | ||
|
||
const THEME = { | ||
colors: { | ||
primary: 'black', | ||
secondary: 'white', | ||
}, | ||
space: { | ||
s: 10, | ||
m: 20, | ||
}, | ||
sizes: { | ||
l: 30, | ||
xl: 40, | ||
}, | ||
shadows: { | ||
strong: { | ||
color: 'primary', | ||
offset: { height: 's', width: 's' }, | ||
opacity: 0.4, | ||
radius: 30, | ||
}, | ||
light: { | ||
color: 'secondary', | ||
offset: { width: 'xl' }, | ||
opacity: 0.4, | ||
radius: 30, | ||
}, | ||
medium: { | ||
elevation: 2, | ||
color: 'secondary', | ||
offset: { height: 30 }, | ||
opacity: 0.4, | ||
}, | ||
custom: { | ||
color: 'not inside theme', | ||
offset: undefined, | ||
}, | ||
noOffset: { | ||
offset: {}, | ||
}, | ||
}, | ||
} as any; | ||
|
||
afterAll(() => { | ||
theme.set(THEME); | ||
}); | ||
|
||
describe('shadows', () => { | ||
beforeAll(() => { | ||
theme.set(THEME); | ||
}); | ||
afterAll(() => { | ||
theme.reset(); | ||
}); | ||
|
||
test('should generate the property `boxShadow` based on the strong shadow', () => { | ||
const result = parsers.resolve({ style: { shadow: 'strong' } }); | ||
expect(result).toEqual({ | ||
shadowColor: 'black', | ||
shadowOffset: { height: 10, width: 10 }, | ||
shadowOpacity: 0.4, | ||
shadowRadius: 30, | ||
}); | ||
}); | ||
|
||
test('should generate the property `shadow` based on the light shadow', () => { | ||
const result = parsers.resolve({ style: { shadow: 'light' } }); | ||
expect(result).toEqual({ | ||
shadowColor: 'white', | ||
shadowOffset: { height: 0, width: 40 }, | ||
shadowOpacity: 0.4, | ||
shadowRadius: 30, | ||
}); | ||
}); | ||
|
||
test('should generate the property `shadow` based on the medium shadow', () => { | ||
const result = parsers.resolve({ style: { shadow: 'medium' } }); | ||
expect(result).toEqual({ | ||
elevation: 2, | ||
shadowColor: 'white', | ||
shadowOffset: { height: 30, width: 0 }, | ||
shadowOpacity: 0.4, | ||
}); | ||
}); | ||
|
||
test('should return an empty object if the shadow is not found', () => { | ||
const result = parsers.resolve({ style: { shadow: 'none' } }); | ||
expect(result).toEqual({}); | ||
}); | ||
|
||
test('should use custom colors if they are not inside the theme', () => { | ||
const result = parsers.resolve({ | ||
style: { shadow: 'custom' as any }, | ||
}); | ||
expect(result).toEqual({ | ||
shadowColor: 'not inside theme', | ||
}); | ||
}); | ||
|
||
test('should not put any value with any empty configuration', () => { | ||
const result = parsers.resolve({ | ||
style: { shadow: 'noOffset' as any }, | ||
}); | ||
expect(result).toEqual({}); | ||
}); | ||
|
||
test('should return an empty object if `shadowOffset` is undefined', () => { | ||
const result = shadowOffset({ | ||
value: undefined, | ||
}); | ||
expect(result).toEqual({}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.