Skip to content

Commit

Permalink
simplifying components, added === true on conditional props
Browse files Browse the repository at this point in the history
  • Loading branch information
nikoloza committed Oct 20, 2024
1 parent 4b7f817 commit f558ae0
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 21 deletions.
1 change: 1 addition & 0 deletions packages/preview/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

export * from './pages/Colors'
export * from './pages/Styleguide'
export * from './pages/Component'
export * from './pages/Components'
7 changes: 7 additions & 0 deletions packages/preview/pages/Colors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

export const Colors = {
}

export const Themes = {
}
2 changes: 1 addition & 1 deletion packages/preview/pages/Styleguide.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Colors, Typography, Shadows, Icons, Spacing, Shapes } from '../articles'

export const StyleguidePage = {
export const Styleguide = {
extend: 'Flex',
tag: 'main',

Expand Down
4 changes: 2 additions & 2 deletions packages/uikit/Atoms/Media.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,14 @@ const applyVariableProps = (key, props, result, element) => {

const applyConditionalCaseProps = (key, props, result, element) => {
const caseKey = key.slice(1)
const isPropTrue = element.props[caseKey] || element.state[caseKey] || element[caseKey]
const isPropTrue = element.props[caseKey] === true || element.state[caseKey] || element[caseKey]
if (!isPropTrue) return // remove classname if not here
return overwriteDeep(result, convertPropsToClass(props, result, element))
}

const applyConditionalFalsyProps = (key, props, result, element) => {
const caseKey = key.slice(1)
const isPropTrue = element.props[caseKey] || element.state[caseKey] || element[caseKey]
const isPropTrue = element.props[caseKey] === true || element.state[caseKey] || element[caseKey]
if (!isPropTrue) return overwriteDeep(result, convertPropsToClass(props, result, element))
}

Expand Down
4 changes: 2 additions & 2 deletions packages/uikit/Avatar/symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const extend = 'Avatar'
const state = {}
const props = {}

const component = {
const value = {
extend: Avatar
}

Expand All @@ -29,7 +29,7 @@ export default {
category,
extend,

component,
value,
code,
state,
props,
Expand Down
14 changes: 7 additions & 7 deletions packages/uikit/Dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const DropdownList = {
style: { listStyleType: 'none' },
transition: 'B defaultBezier',
transitionProperty: 'transform, opacity, visibility',
children: ({ props }) => props.options || [],
childrenAs: 'props',

'.hidden': {
transform: 'translate3d(0,10%,0)',
Expand All @@ -27,8 +29,8 @@ export const DropdownList = {
childExtend: {
extend: 'Button',
state: {},
props: ({ key, state }) => ({
active: state.active === key,
props: {
isActive: ({ key, state }) => state.active === key,
position: 'relative',
round: '0',
align: 'center flex-end',
Expand All @@ -45,7 +47,7 @@ export const DropdownList = {
},

Icon: {
active: state.active === key,
isActive: ({ key, state }) => state.active === key,
name: 'checkmark',
opacity: '0.1',
'.active': { opacity: '1' }
Expand All @@ -56,10 +58,8 @@ export const DropdownList = {
'@light': { border: 'gray11, solid' },
borderWidth: '1px 0 0'
}
})
},

$propsCollection: ({ props }) => props.options
}
}
}

export const DropdownParent = {
Expand Down
4 changes: 2 additions & 2 deletions packages/uikit/Pills/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export const Pills = {
boxSize: 'Y2',
round: 'A',
background: 'currentColor',
active: parseInt(key) === parseInt(state.active || parent.props.active),
'!active': { opacity: 0.35 }
isActive: parseInt(key) === parseInt(state.active || parent.props.active),
'!isActive': { opacity: 0.35 }
})
},
on: {
Expand Down
12 changes: 5 additions & 7 deletions packages/uikit/TimePicker/TimeSwitcher.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict'

import { Button } from '@symbo.ls/button'

const props = {
boxSize: 'C B2',
flow: 'column',
Expand All @@ -15,9 +13,8 @@ export const TimeSwitcher = {
extend: 'Flex',

childExtend: {
extend: Button,
props: ({ state, key }) => ({
active: state.activeShift === key,
extend: 'Button',
props: {
padding: '0',
flex: '1',
width: '100%',
Expand All @@ -27,8 +24,9 @@ export const TimeSwitcher = {
background: 'transparent',
color: 'currentColor',
lineHeight: '1',
'.active': { theme: 'primary' }
}),
isActive: ({ state, key }) => state.activeShift === key,
'.isActive': { theme: 'primary' }
},
on: {
click: (ev, { key, state }) => {
state.update({ activeShift: key })
Expand Down

0 comments on commit f558ae0

Please sign in to comment.