Skip to content

Commit

Permalink
Refactored button
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurczewski committed Sep 26, 2024
1 parent 667362b commit 90d0706
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions libs/generic-view/models/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import { entitiesLoader } from "./lib/entities-loader"
import { conditionalRenderer } from "./lib/conditional-renderer"
import { toast } from "./lib/toast"
import { selectionManager } from "./lib/selection-manager"
import { formatMessage } from "./lib/format-message"

export * from "./lib/block-box"
export * from "./lib/block-plain"
Expand Down Expand Up @@ -111,6 +112,7 @@ export * from "./lib/form-conditional-renderer"
export * from "./lib/entities-loader"
export * from "./lib/common-validators"
export * from "./lib/conditional-renderer"
export * from "./lib/format-message"
export * from "./lib/toast"
export * from "./lib/selection-manager"

Expand Down Expand Up @@ -169,6 +171,7 @@ export default {
[tableCell.key]: tableCell,
[entitiesLoader.key]: entitiesLoader,
[conditionalRenderer.key]: conditionalRenderer,
[formatMessage.key]: formatMessage,
[toast.key]: toast,
[selectionManager.key]: selectionManager,
} as const
2 changes: 1 addition & 1 deletion libs/generic-view/models/src/lib/button-primary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { buttonActionsValidator } from "./common-validators"
const dataValidator = z.undefined()

const configValidator = z.object({
text: z.string(),
text: z.string().optional(),
icon: z.nativeEnum(IconType).optional(),
actions: buttonActionsValidator,
disabled: z.boolean().optional(),
Expand Down
2 changes: 1 addition & 1 deletion libs/generic-view/ui/src/lib/buttons/button-primary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ButtonPrimary: APIFC<undefined, ButtonPrimaryConfig> = ({
<Button {...props} disabled={config.disabled} actions={config.actions}>
{children}
{config.icon && <Icon data={{ type: config.icon }} />}
<span>{config.text}</span>
{config.text ? <span>{config.text}</span> : null}
</Button>
)
}
Expand Down
3 changes: 3 additions & 0 deletions libs/generic-view/ui/src/lib/interactive/interactive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import { ProgressBar } from "./progress-bar/progress-bar"
import Form from "./form/form"
import Tooltip from "./tooltip/tooltip"
import { Toast } from "./toast/toast"
import { ConditionalRenderer } from "./conditional-renderer"
import {
conditionalRenderer,
form,
formatMessage,
formCheckboxInput,
Expand Down Expand Up @@ -56,4 +58,5 @@ export const interactive = {
[tooltipContent.key]: Tooltip.Content,
[formatMessage.key]: FormatMessage,
[toast.key]: Toast,
[conditionalRenderer.key]: ConditionalRenderer,
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const ModalTitleIcon: APIFC<undefined, ModalTitleIconConfig> = ({
children,
...rest
}) => {
// @ts-ignore
return <TitleIcon config={config} {...rest} />
}

Expand Down

0 comments on commit 90d0706

Please sign in to comment.