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

feature(component): Rewrite Buttons to use themes, resolves #130 #160

Merged
merged 8 commits into from
Jun 3, 2022

Conversation

tulup-conner
Copy link
Collaborator

@tulup-conner tulup-conner commented May 27, 2022

Breaking changes

Buttons and Button.Groups can now be customized using <Flowbite theme={..}>.

button: {
  base: 'group flex h-min w-fit items-center justify-center p-0.5 text-center font-medium focus:z-10',
  color: {
    dark: 'text-white bg-gray-800 border border-transparent hover:bg-gray-900 focus:ring-4 focus:ring-gray-300 disabled:hover:bg-gray-800 dark:bg-gray-800 dark:hover:bg-gray-700 dark:focus:ring-gray-800 dark:border-gray-700 dark:disabled:hover:bg-gray-800',
    failure:
      'text-white bg-red-700 border border-transparent hover:bg-red-800 focus:ring-4 focus:ring-red-300 disabled:hover:bg-red-800 dark:bg-red-600 dark:hover:bg-red-700 dark:focus:ring-red-900 dark:disabled:hover:bg-red-600',
    gray: 'text-gray-900 bg-white border border-gray-200 hover:bg-gray-100 hover:text-blue-700 disabled:hover:bg-white focus:ring-blue-700 focus:text-blue-700 dark:bg-transparent dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700 focus:ring-2 dark:disabled:hover:bg-gray-800',
    info: 'text-white bg-blue-700 border border-transparent hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 disabled:hover:bg-blue-700 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800 dark:disabled:hover:bg-blue-600',
    light:
      'text-gray-900 bg-white border border-gray-300 hover:bg-gray-100 focus:ring-4 focus:ring-blue-300 disabled:hover:bg-white dark:bg-gray-600 dark:text-white dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-700 dark:focus:ring-gray-700',
    purple:
      'text-white bg-purple-700 border border-transparent hover:bg-purple-800 focus:ring-4 focus:ring-purple-300 disabled:hover:bg-purple-700 dark:bg-purple-600 dark:hover:bg-purple-700 dark:focus:ring-purple-900 dark:disabled:hover:bg-purple-600',
    success:
      'text-white bg-green-700 border border-transparent hover:bg-green-800 focus:ring-4 focus:ring-green-300 disabled:hover:bg-green-700 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800 dark:disabled:hover:bg-green-600',
    warning:
      'text-white bg-yellow-400 border border-transparent hover:bg-yellow-500 focus:ring-4 focus:ring-yellow-300 disabled:hover:bg-yellow-400 dark:focus:ring-yellow-900 dark:disabled:hover:bg-yellow-400',
  },
  disabled: 'cursor-not-allowed opacity-50',
  gradient: {
    cyan: 'text-white bg-gradient-to-r from-cyan-400 via-cyan-500 to-cyan-600 hover:bg-gradient-to-br focus:ring-4 focus:ring-cyan-300 dark:focus:ring-cyan-800',
    failure:
      'text-white bg-gradient-to-r from-red-400 via-red-500 to-red-600 hover:bg-gradient-to-br focus:ring-4 focus:ring-red-300 dark:focus:ring-red-800',
    info: 'text-white bg-gradient-to-r from-blue-500 via-blue-600 to-blue-700 hover:bg-gradient-to-br focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800 ',
    lime: 'text-gray-900 bg-gradient-to-r from-lime-200 via-lime-400 to-lime-500 hover:bg-gradient-to-br focus:ring-4 focus:ring-lime-300 dark:focus:ring-lime-800',

    pink: 'text-white bg-gradient-to-r from-pink-400 via-pink-500 to-pink-600 hover:bg-gradient-to-br focus:ring-4 focus:ring-pink-300 dark:focus:ring-pink-800',
    purple:
      'text-white bg-gradient-to-r from-purple-500 via-purple-600 to-purple-700 hover:bg-gradient-to-br focus:ring-4 focus:ring-purple-300 dark:focus:ring-purple-800',
    success:
      'text-white bg-gradient-to-r from-green-400 via-green-500 to-green-600 hover:bg-gradient-to-br focus:ring-4 focus:ring-green-300 dark:focus:ring-green-800',
    teal: 'text-white bg-gradient-to-r from-teal-400 via-teal-500 to-teal-600 hover:bg-gradient-to-br focus:ring-4 focus:ring-teal-300 dark:focus:ring-teal-800',
  },
  gradientDuoTone: {
    cyanToBlue:
      'text-white bg-gradient-to-r from-cyan-500 to-blue-500 hover:bg-gradient-to-bl focus:ring-4 focus:ring-cyan-300 dark:focus:ring-cyan-800',
    greenToBlue:
      'text-white bg-gradient-to-br from-green-400 to-blue-600 hover:bg-gradient-to-bl focus:ring-4 focus:ring-green-200 dark:focus:ring-green-800',
    pinkToOrange:
      'text-white bg-gradient-to-br from-pink-500 to-orange-400 hover:bg-gradient-to-bl focus:ring-4 focus:ring-pink-200 dark:focus:ring-pink-800',
    purpleToBlue:
      'text-white bg-gradient-to-br from-purple-600 to-blue-500 hover:bg-gradient-to-bl focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-800',
    purpleToPink:
      'text-white bg-gradient-to-r from-purple-500 to-pink-500 hover:bg-gradient-to-l focus:ring-4 focus:ring-purple-200 dark:focus:ring-purple-800',
    redToYellow:
      'text-gray-900 bg-gradient-to-r from-red-200 via-red-300 to-yellow-200 hover:bg-gradient-to-bl focus:ring-4 focus:ring-red-100 dark:focus:ring-red-400',
    tealToLime:
      'text-gray-900 bg-gradient-to-r from-teal-200 to-lime-200 hover:bg-gradient-to-l hover:from-teal-200 hover:to-lime-200 hover:!text-gray-900 focus:ring-4 focus:ring-lime-200 dark:focus:ring-teal-700',
  },
  inner: {
    base: 'flex items-center',
    position: {
      none: '',
      start: 'rounded-r-none',
      middle: '!rounded-none',
      end: 'rounded-l-none',
    },
  },
  label:
    'ml-2 inline-flex h-4 w-4 items-center justify-center rounded-full bg-blue-200 text-xs font-semibold text-blue-800',
  outline: {
    off: '',
    on: 'bg-white text-gray-900 transition-all duration-75 ease-in group-hover:bg-opacity-0 group-hover:text-inherit dark:bg-gray-900 dark:text-white',
    pill: {
      off: 'rounded-md',
      on: 'rounded-full',
    },
  },
  pill: {
    off: 'rounded-lg',
    on: 'rounded-full',
  },
  position: {
    none: 'focus:!ring-2',
    start: 'rounded-r-none',
    middle: '!rounded-none border-l-0 pl-0',
    end: 'rounded-l-none border-l-0 pl-0',
  },
  size: {
    xs: 'text-xs px-2 py-1',
    sm: 'text-sm px-3 py-1.5',
    md: 'text-sm px-4 py-2',
    lg: 'text-base px-5 py-2.5',
    xl: 'text-base px-6 py-3',
  },
},
buttonGroup: {
  base: 'inline-flex',
  position: {
    none: 'focus:!ring-2',
    start: 'rounded-r-none',
    middle: '!rounded-none border-l-0 pl-0',
    end: 'rounded-l-none border-l-0 pl-0',
  },
},

Features

Tests

Unit

@tulup-conner tulup-conner force-pushed the feature/buttons-theme branch 8 times, most recently from df435c7 to 159cab8 Compare May 28, 2022 05:17
@tulup-conner tulup-conner marked this pull request as ready for review May 28, 2022 05:23
@tulup-conner tulup-conner marked this pull request as draft May 28, 2022 05:27
@tulup-conner tulup-conner force-pushed the feature/buttons-theme branch from fc3bc98 to ed3ca4f Compare May 28, 2022 05:39
@tulup-conner tulup-conner marked this pull request as ready for review May 28, 2022 05:46
@tulup-conner tulup-conner force-pushed the feature/buttons-theme branch from ed3ca4f to 9140a24 Compare May 28, 2022 23:01
src/lib/theme/default.ts Show resolved Hide resolved
@tulup-conner tulup-conner force-pushed the feature/buttons-theme branch from 9140a24 to 719c9bb Compare May 31, 2022 06:59
@tulup-conner tulup-conner requested a review from rluders May 31, 2022 07:02
@rluders rluders linked an issue Jun 2, 2022 that may be closed by this pull request
@tulup-conner tulup-conner force-pushed the feature/buttons-theme branch from 719c9bb to 4ef5b9c Compare June 3, 2022 00:16
Now that we are actually using `mergeDeep` for
`<Flowbite theme={..}>`, I wanted to update this
spec to more accurately reflect the use cases we
need to solve.
The combination of `outline={true}` and `color="gray"`
triggers a set of special classes. So I set up the
API like so:

```js
outline: {
  base: '..',
  color: {
    gray: 'special case classes',
    ... any other special cases the user may need to accomodate
  },
  ..
}
```
@tulup-conner tulup-conner force-pushed the feature/buttons-theme branch from 4ef5b9c to 13f3cf4 Compare June 3, 2022 00:23
@rluders rluders merged commit 9055aa8 into themesberg:main Jun 3, 2022
@tulup-conner tulup-conner deleted the feature/buttons-theme branch June 4, 2022 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Theme: Button component
2 participants