Skip to content

Commit

Permalink
be smarter about where event-color css is attached
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed May 19, 2020
1 parent 112d273 commit 0cd006b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages-premium
6 changes: 2 additions & 4 deletions packages/common/src/common/EventRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Seg } from '../component/DateComponent'
import { ComponentChildren, createElement, Ref, createRef } from '../vdom'
import { EventApi } from '../api/EventApi'
import { computeSegDraggable, computeSegStartResizable, computeSegEndResizable, setElSeg } from '../component/event-rendering'
import { EventMeta, getSkinCss, getEventClassNames } from '../component/event-rendering'
import { EventMeta, getEventClassNames } from '../component/event-rendering'
import { RenderHook } from './render-hook'
import { BaseComponent } from '../vdom-util'

Expand All @@ -26,7 +26,6 @@ export interface EventRootProps extends MinimalEventProps {
children: (
rootElRef: Ref<any>,
classNames: string[],
style: any,
innerElRef: Ref<any>,
innerContent: ComponentChildren,
hookProps: EventMeta
Expand Down Expand Up @@ -67,7 +66,6 @@ export class EventRoot extends BaseComponent<EventRootProps> {
isResizing: Boolean(props.isResizing)
}

let style = getSkinCss(ui)
let standardClassNames = getEventClassNames(hookProps).concat(ui.classNames)

return (
Expand All @@ -81,7 +79,7 @@ export class EventRoot extends BaseComponent<EventRootProps> {
elRef={this.elRef}
>
{(rootElRef, customClassNames, innerElRef, innerContent) => props.children(
rootElRef, standardClassNames.concat(customClassNames), style, innerElRef, innerContent, hookProps
rootElRef, standardClassNames.concat(customClassNames), innerElRef, innerContent, hookProps
)}
</RenderHook>
)
Expand Down
17 changes: 10 additions & 7 deletions packages/common/src/common/StandardEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export class StandardEvent extends BaseComponent<StandardEventProps> {

render() {
let { props, context } = this

let { seg } = props
let timeFormat = context.options.eventTimeFormat || props.defaultTimeFormat
let timeText = buildSegTimeText(props.seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd)
let timeText = buildSegTimeText(seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd)

return (
<EventRoot
seg={props.seg}
seg={seg}
timeText={timeText}
disableDragging={props.disableDragging}
disableResizing={props.disableResizing}
Expand All @@ -42,14 +42,17 @@ export class StandardEvent extends BaseComponent<StandardEventProps> {
isFuture={props.isFuture}
isToday={props.isToday}
>
{(rootElRef, classNames, style, innerElRef, innerContent, hookProps) => (
{(rootElRef, classNames, innerElRef, innerContent, hookProps) => (
<a
className={props.extraClassNames.concat(classNames).join(' ')}
style={style}
style={{
borderColor: hookProps.borderColor,
backgroundColor: hookProps.backgroundColor
}}
ref={rootElRef}
{...getSegAnchorAttrs(props.seg)}
{...getSegAnchorAttrs(seg)}
>
<div className='fc-event-main' ref={innerElRef}>
<div className='fc-event-main' ref={innerElRef} style={{ color: hookProps.textColor }}>
{innerContent}
</div>
{hookProps.isStartResizable &&
Expand Down
10 changes: 8 additions & 2 deletions packages/common/src/common/bg-fill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ export const BgEvent = (props: BgEventProps) => (
isFuture={props.isFuture}
isToday={props.isToday}
>
{(rootElRef, classNames, style, innerElRef, innerContent) => (
<div ref={rootElRef} className={[ 'fc-bg-event' ].concat(classNames).join(' ')} style={style}>
{(rootElRef, classNames, innerElRef, innerContent, hookProps) => (
<div
ref={rootElRef}
className={[ 'fc-bg-event' ].concat(classNames).join(' ')}
style={{
backgroundColor: hookProps.backgroundColor
}}
>
{innerContent}
</div>
)}
Expand Down
9 changes: 0 additions & 9 deletions packages/common/src/component/event-rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,3 @@ export function getEventClassNames(props: EventMeta) { // weird that we use this

return classNames
}


export function getSkinCss(ui: EventUi) {
return {
backgroundColor: ui.backgroundColor,
borderColor: ui.borderColor,
color: ui.textColor
}
}
6 changes: 2 additions & 4 deletions packages/daygrid/src/TableListItemEvent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export class TableListItemEvent extends BaseComponent<DotTableEventProps> {

render() {
let { props, context } = this


let timeFormat = context.options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT
let timeText = buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd)

Expand All @@ -34,11 +32,11 @@ export class TableListItemEvent extends BaseComponent<DotTableEventProps> {
isFuture={props.isFuture}
isToday={props.isToday}
>
{(rootElRef, classNames, style, innerElRef, innerContent, innerProps) => ( // we don't use styles!
{(rootElRef, classNames, innerElRef, innerContent, hookProps) => ( // we don't use styles!
<a
className={[ 'fc-daygrid-event', 'fc-daygrid-dot-event' ].concat(classNames).join(' ')}
ref={rootElRef}
style={{ color: innerProps.textColor }}
style={{ color: hookProps.textColor }}
{...getSegAnchorAttrs(props.seg)}
>
{innerContent}
Expand Down
8 changes: 3 additions & 5 deletions packages/list/src/ListViewEventRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ export class ListViewEventRow extends BaseComponent<MinimalEventProps> {
isResizing={props.isResizing}
isDateSelecting={props.isDateSelecting}
>
{(rootElRef, classNames, style, innerElRef, innerContent, hookProps) => (
{(rootElRef, classNames, innerElRef, innerContent, hookProps) => (
<tr className={[ 'fc-list-event', hookProps.event.url ? 'fc-event-forced-url' : '' ].concat(classNames).join(' ')} ref={rootElRef}>
{buildTimeContent(seg, timeFormat, context)}
<td className='fc-list-event-graphic'>
<span className='fc-list-event-dot' style={{
backgroundColor: hookProps.event.backgroundColor
}} />
<span className='fc-list-event-dot' style={{ backgroundColor: hookProps.backgroundColor }} />
</td>
<td className='fc-list-event-title' ref={innerElRef}>
<td className='fc-list-event-title' ref={innerElRef} style={{ color: hookProps.textColor }}>
{innerContent}
</td>
</tr>
Expand Down

0 comments on commit 0cd006b

Please sign in to comment.