Skip to content

Commit

Permalink
feat: create message-text plugin component (#29)
Browse files Browse the repository at this point in the history
Co-authored-by: Sacha Stafyniak <sacha@digisquad.io>
  • Loading branch information
bpsmartdesign and stafyniaksacha authored Jul 23, 2023
1 parent 10cd58c commit 3d28052
Show file tree
Hide file tree
Showing 2 changed files with 259 additions and 0 deletions.
73 changes: 73 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,79 @@ export default withShurikenUI({
text: 'primary-800',
textDark: 'primary-200',
},
messageText: {
space: '6',
head: {
space: '2',
},
dot: {
size: '3',
rounded: 'full',
bg: 'muted-200',
bgDark: 'muted-700',
},
close: {
position: '2',
},
white: {
bg: 'white',
bgDark: 'muted-800',
},
whiteContrast: {
bg: 'white',
bgDark: 'muted-950',
},
default: {
border: 'muted-300',
borderDark: 'muted-700',
dot: {
bg: 'muted-200',
bgDark: 'muted-700',
},
},
contrast: {
border: 'muted-300',
borderDark: 'muted-800',
dot: {
bg: 'muted-200',
bgDark: 'muted-800',
},
},
primary: {
border: 'primary-500',
dot: {
bg: 'primary-500',
},
},
info: {
border: 'info-500',
dot: {
bg: 'info-500',
},
},
success: {
border: 'success-500',
dot: {
bg: 'success-500',
},
},
warning: {
border: 'warning-500',
dot: {
bg: 'warning-500',
},
},
danger: {
border: 'danger-500',
dot: {
bg: 'danger-500',
},
},
rounded: {
default: 'md',
smooth: 'lg',
curved: 'xl',
},
progress: {
size: 'full',
bar: {
Expand Down
186 changes: 186 additions & 0 deletions src/plugins/components/message-text.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
import plugin from 'tailwindcss/plugin'
import { defu } from 'defu'
import { type PluginOption, defaultPluginOptions } from '../options'

const defaultMessageTextConfig = {
space: '6',
head: {
space: '2',
},
dot: {
size: '3',
rounded: 'full',
bg: 'muted-200',
bgDark: 'muted-700',
},
close: {
position: '2',
},
white: {
bg: 'white',
bgDark: 'muted-800',
},
whiteContrast: {
bg: 'white',
bgDark: 'muted-950',
},
default: {
border: 'muted-300',
borderDark: 'muted-700',
dot: {
bg: 'muted-200',
bgDark: 'muted-700',
},
},
contrast: {
border: 'muted-300',
borderDark: 'muted-800',
dot: {
bg: 'muted-200',
bgDark: 'muted-800',
},
},
primary: {
border: 'primary-500',
dot: {
bg: 'primary-500',
},
},
info: {
border: 'info-500',
dot: {
bg: 'info-500',
},
},
success: {
border: 'success-500',
dot: {
bg: 'success-500',
},
},
warning: {
border: 'warning-500',
dot: {
bg: 'warning-500',
},
},
danger: {
border: 'danger-500',
dot: {
bg: 'danger-500',
},
},
rounded: {
default: 'md',
smooth: 'lg',
curved: 'xl',
},
}

export default plugin.withOptions(
function (options: PluginOption) {
const { prefix } = defu(options, defaultPluginOptions)

return function ({ addComponents, theme }) {
const config = theme(
'shurikenUi.messageText'
) satisfies typeof defaultMessageTextConfig

addComponents({
[`.${prefix}-message-text`]: {
[`@apply relative p-${config.space}`]: {},

[`.${prefix}-message-head`]: {
[`@apply flex items-center gap-${config.head.space} mb-2`]: {},
},
[`.${prefix}-message-dot`]: {
[`@apply inline-block h-${config.dot.size} w-${config.dot.size} rounded-${config.dot.rounded} bg-${config.dot.bg} dark:bg-${config.dot.bgDark}`]:
{},
},
[`.${prefix}-message-close`]: {
[`@apply absolute top-${config.close.position} end-${config.close.position}`]:
{},
},
[`&.${prefix}-message-white`]: {
[`@apply bg-${config.white.bg} dark:bg-${config.white.bgDark}`]: {},
},
[`&.${prefix}-message-white-contrast`]: {
[`@apply bg-${config.whiteContrast.bg} dark:bg-${config.whiteContrast.bgDark}`]:
{},
},
[`&.${prefix}-message-rounded`]: {
[`@apply rounded-${config.rounded.default}`]: {},
},
[`&.${prefix}-message-smooth`]: {
[`@apply rounded-${config.rounded.smooth}`]: {},
},
[`&.${prefix}-message-curved`]: {
[`@apply rounded-${config.rounded.curved}`]: {},
},
[`&.${prefix}-message-default`]: {
[`@apply border border-${config.default.border} dark:border-${config.default.borderDark}`]:
{},

[`.${prefix}-message-dot`]: {
[`@apply bg-${config.default.dot.bg} dark:bg-${config.default.dot.bgDark}`]:
{},
},
},
[`&.${prefix}-message-contrast`]: {
[`@apply border border-${config.contrast.border} dark:border-${config.contrast.borderDark}`]:
{},

[`.${prefix}-message-dot`]: {
[`@apply bg-${config.contrast.dot.bg} dark:bg-${config.contrast.dot.bgDark}`]:
{},
},
},
[`&.${prefix}-message-primary`]: {
[`@apply border border-${config.primary.border}`]: {},

[`.${prefix}-message-dot`]: {
[`@apply bg-${config.primary.dot.bg}`]: {},
},
},
[`&.${prefix}-message-info`]: {
[`@apply border border-${config.info.border}`]: {},

[`.${prefix}-message-dot`]: {
[`@apply bg-${config.info.dot.bg}`]: {},
},
},
[`&.${prefix}-message-success`]: {
[`@apply border border-${config.success.border}`]: {},

[`.${prefix}-message-dot`]: {
[`@apply bg-${config.success.dot.bg}`]: {},
},
},
[`&.${prefix}-message-warning`]: {
[`@apply border border-${config.warning.border}`]: {},

[`.${prefix}-message-dot`]: {
[`@apply bg-${config.warning.dot.bg}`]: {},
},
},
[`&.${prefix}-message-danger`]: {
[`@apply border border-${config.danger.border}`]: {},

[`.${prefix}-message-dot`]: {
[`@apply bg-${config.danger.dot.bg}`]: {},
},
},
},
})
}
},
function () {
return {
theme: {
shurikenUi: {
messageText: defaultMessageTextConfig,
},
},
}
}
)

0 comments on commit 3d28052

Please sign in to comment.