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

Add cursor style option #25

Merged
merged 7 commits into from
Apr 24, 2019
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Added
- Support specifying item elements and scrollable container element, by [@compulim](https://github.com/compulim) in PR [#21](https://github.com/spyip/react-film/pull/21).
- Fix [#22](https://github.com/spyip/react-film/issues/22). Added style options to hide "cursor: pointer" style, by [@compulim](https://github.com/compulim) in PR [#25](https://github.com/spyip/react-film/pull/25).

### Changed
- For performance reason, deep-customizing component will now need to pass `numItems` prop to `<Composer>`, by [@compulim](https://github.com/compulim) in PR [#21](https://github.com/spyip/react-film/pull/21).
Expand Down
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,16 @@ export default props =>

Sometimes, just increasing some paddings are more than enough for your styling need. When calling `createBasicStyleSet(options)`, you can specify the following options:

| Name | Default | Description |
|-------------------|---------|-------------------------------|
| `autoHide` | `true` | Auto-hide controls |
| `dotBoxSize` | `20` | Hit box size of every dot |
| `dotSize` | `6` | Visible dot size |
| `flipperBoxWidth` | `60` | Hit box size of flippers |
| `flipperSize` | `40` | Visible flipper size (circle) |
| `scrollBarHeight` | `8` | Scroll bar handler height |
| `scrollBarMargin` | `4` | Margin around scroll bar |
| Name | Default | Description |
|-------------------|-----------|-----------------------------------|
| `autoHide` | `true` | Auto-hide controls |
| `cursor` | `pointer` | Cursor style on dots and flippers |
| `dotBoxSize` | `20` | Hit box size of every dot |
| `dotSize` | `6` | Visible dot size |
| `flipperBoxWidth` | `60` | Hit box size of flippers |
| `flipperSize` | `40` | Visible flipper size (circle) |
| `scrollBarHeight` | `8` | Scroll bar handler height |
| `scrollBarMargin` | `4` | Margin around scroll bar |

# Deep-customization

Expand Down
1 change: 0 additions & 1 deletion packages/component/src/Dots.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const DOT_CSS = css({
position: 'relative',

'& > input': {
cursor: 'pointer',
height: '100%',
left: 0,
margin: 0,
Expand Down
27 changes: 15 additions & 12 deletions packages/component/src/createBasicStyleSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ const createDotsBoxCSS = ({ height }) => css({
width: '100%'
});

const createDotsItemCSS = ({ boxSize, size }) => css({
const createDotsItemCSS = ({ boxSize, cursor, size }) => css({
alignItems: 'center',
display: 'flex',
height: boxSize,
justifyContent: 'center',
width: boxSize,

'& > input': {
cursor: 'pointer',
...cursor ? { cursor } : {},

height: '100%',
left: 0,
margin: 0,
Expand Down Expand Up @@ -52,9 +53,10 @@ const createDotsItemCSS = ({ boxSize, size }) => css({
const FLIPPER_BOX_WIDTH = 60;
const FLIPPER_SIZE = 40;

const createFlipperBoxCSS = ({ boxWidth, size }) => css({
const createFlipperBoxCSS = ({ boxWidth, cursor, size }) => css({
...cursor ? { cursor } : {},

background: 'Transparent',
cursor: 'pointer',
height: '100%',
position: 'absolute',
top: 0,
Expand Down Expand Up @@ -115,7 +117,7 @@ const createRightFlipperCSS = options => css({
const SCROLL_BAR_HEIGHT = 8;
const SCROLL_BAR_MARGIN = 4;

const createScrollBarBoxCSS = ({ height, margin }) => css({
const createScrollBarBoxCSS = ({ margin }) => css({
bottom: 0,
padding: margin,
position: 'absolute',
Expand All @@ -125,15 +127,16 @@ const createScrollBarBoxCSS = ({ height, margin }) => css({
width: '100%'
});

const createScrollBarHandlerCSS = ({ height, margin }) => css({
const createScrollBarHandlerCSS = ({ height }) => css({
backdropFilter: 'blur(4px)',
background: 'rgba(255, 255, 255, .4)',
borderRadius: height / 2,
height: height
height
});

export default function ({
autoHide = true,
cursor = 'pointer',
dotBoxSize = DOT_BOX_SIZE,
dotSize = DOT_SIZE,
flipperBoxWidth = FLIPPER_BOX_WIDTH,
Expand All @@ -144,11 +147,11 @@ export default function ({
const styles = {
carousel : '',
dotsBox : createDotsBoxCSS({ height: dotBoxSize }),
dotsItem : createDotsItemCSS({ boxSize: dotBoxSize, size: dotSize }),
leftFlipper : createLeftFlipperCSS({ boxWidth: flipperBoxWidth, size: flipperSize }),
rightFlipper : createRightFlipperCSS({ boxWidth: flipperBoxWidth, size: flipperSize }),
scrollBarBox : createScrollBarBoxCSS({ height: scrollBarHeight, margin: scrollBarMargin }),
scrollBarHandler: createScrollBarHandlerCSS({ height: scrollBarHeight, margin: scrollBarMargin })
dotsItem : createDotsItemCSS({ boxSize: dotBoxSize, cursor, size: dotSize }),
leftFlipper : createLeftFlipperCSS({ boxWidth: flipperBoxWidth, cursor, size: flipperSize }),
rightFlipper : createRightFlipperCSS({ boxWidth: flipperBoxWidth, cursor, size: flipperSize }),
scrollBarBox : createScrollBarBoxCSS({ margin: scrollBarMargin }),
scrollBarHandler: createScrollBarHandlerCSS({ height: scrollBarHeight })
};

// This is for overriding existing rules with auto-hide CSS transitions
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const LIST_FILM_ITEM_CSS = css({
width: 200
});

const styleSet = createBasicStyleSet({ autoHide: false });
const styleSet = createBasicStyleSet({ autoHide: false, cursor: null });
const myStyleSet = {
...styleSet,
scrollBarHandler: styleSet.scrollBarHandler + ' ' + css({ backgroundColor: 'Red' })
Expand Down