Skip to content

Commit 57483e5

Browse files
authored
Merge pull request #965 from wKovacs64/variants
Add variants to Theme interface
2 parents 2c72fa1 + 001cde8 commit 57483e5

File tree

2 files changed

+136
-13
lines changed

2 files changed

+136
-13
lines changed

packages/css/src/types.ts

Lines changed: 135 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,10 @@ export interface Theme {
586586
radii?: ObjectOrArray<CSS.BorderRadiusProperty<TLengthStyledSystem>>
587587
shadows?: ObjectOrArray<CSS.BoxShadowProperty>
588588
zIndices?: ObjectOrArray<CSS.ZIndexProperty>
589-
buttons?: ObjectOrArray<ThemeUICSSProperties>
590589
colorStyles?: ObjectOrArray<ThemeUICSSProperties>
591590
textStyles?: ObjectOrArray<ThemeUICSSProperties>
592-
text?: ObjectOrArray<ThemeUICSSProperties>
593591
opacities?: ObjectOrArray<CSS.OpacityProperty>
592+
594593
/**
595594
* Enable/disable custom CSS properties/variables if lower browser
596595
* support is required (for eg. IE 11).
@@ -637,4 +636,138 @@ export interface Theme {
637636
* fonts, etc.
638637
*/
639638
styles?: ThemeStyles
639+
640+
/**
641+
* You can define additional CSS grid layouts by adding variants to the
642+
* `theme.grids` object. These styles can be used to create a wide variety of
643+
* different reusable layouts.
644+
*
645+
* @see https://theme-ui.com/theme-spec#variants
646+
* @see https://theme-ui.com/components/variants
647+
* @see https://theme-ui.com/components/grid#variants
648+
*/
649+
grids?: Record<string, ThemeUIStyleObject>
650+
651+
/**
652+
* Button variants can be defined in the `theme.buttons` object. The `Button`
653+
* component uses `theme.buttons.primary` as its default variant style.
654+
*
655+
* @see https://theme-ui.com/theme-spec#variants
656+
* @see https://theme-ui.com/components/variants
657+
* @see https://theme-ui.com/components/button#variants
658+
*/
659+
buttons?: Record<string, ThemeUIStyleObject>
660+
661+
/**
662+
* Text style variants can be defined in the `theme.text` object. The `Text`
663+
* component uses `theme.text.default` as its default variant style.
664+
*
665+
* @see https://theme-ui.com/theme-spec#variants
666+
* @see https://theme-ui.com/components/variants
667+
* @see https://theme-ui.com/components/text#variants
668+
*/
669+
text?: Record<string, ThemeUIStyleObject>
670+
671+
/**
672+
* Link variants can be defined in the `theme.links` object. By default the
673+
* `Link` component will use styles defined in `theme.styles.a`.
674+
*
675+
* @see https://theme-ui.com/theme-spec#variants
676+
* @see https://theme-ui.com/components/variants
677+
* @see https://theme-ui.com/components/link#variants
678+
*/
679+
links?: Record<string, ThemeUIStyleObject>
680+
681+
/**
682+
* Image style variants can be defined in the `theme.images` object.
683+
*
684+
* @see https://theme-ui.com/theme-spec#variants
685+
* @see https://theme-ui.com/components/variants
686+
* @see https://theme-ui.com/components/image#variants
687+
*/
688+
images?: Record<string, ThemeUIStyleObject>
689+
690+
/**
691+
* Card style variants can be defined in `the theme.cards` object. By default
692+
* the `Card` component uses the `theme.cards.primary` variant.
693+
*
694+
* @see https://theme-ui.com/theme-spec#variants
695+
* @see https://theme-ui.com/components/variants
696+
* @see https://theme-ui.com/components/card#variants
697+
*/
698+
cards?: Record<string, ThemeUIStyleObject>
699+
700+
/**
701+
* Container variants can be defined in the `theme.layout` object. The
702+
* `Container` component uses `theme.layout.container` as its default variant
703+
* style.
704+
*
705+
* @see https://theme-ui.com/theme-spec#variants
706+
* @see https://theme-ui.com/components/variants
707+
* @see https://theme-ui.com/components/container#variants
708+
*/
709+
layout?: Record<string, ThemeUIStyleObject>
710+
711+
/**
712+
* Label variants can be defined in `theme.forms` and the component uses the
713+
* `theme.forms.label` variant by default.
714+
*
715+
* Input variants can be defined in `theme.forms` and the component uses the
716+
* `theme.forms.input` variant by default.
717+
*
718+
* Select variants can be defined in `theme.forms` and the component uses the
719+
* `theme.forms.select` variant by default.
720+
*
721+
* Textarea variants can be defined in `theme.forms` and the component uses
722+
* the `theme.forms.textarea` variant by default.
723+
*
724+
* Radio variants can be defined in `theme.forms` and the component uses the
725+
* `theme.forms.radio` variant by default.
726+
*
727+
* Checkbox variants can be defined in `theme.forms` and the component uses
728+
* the `theme.forms.checkbox` variant by default.
729+
*
730+
* Slider variants can be defined in the `theme.forms` object. The `Slider`
731+
* component uses `theme.forms.slider` as its default variant style.
732+
*
733+
* @see https://theme-ui.com/theme-spec#variants
734+
* @see https://theme-ui.com/components/variants
735+
* @see https://theme-ui.com/components/label#variants
736+
* @see https://theme-ui.com/components/input#variants
737+
* @see https://theme-ui.com/components/select#variants
738+
* @see https://theme-ui.com/components/textarea#variants
739+
* @see https://theme-ui.com/components/radio#variants
740+
* @see https://theme-ui.com/components/checkbox#variants
741+
* @see https://theme-ui.com/components/slider#variants
742+
*/
743+
forms?: Record<string, ThemeUIStyleObject>
744+
745+
/**
746+
* Badge variants can be defined in `theme.badges`. The `Badge` component uses
747+
* `theme.badges.primary` as its default variant.
748+
*
749+
* @see https://theme-ui.com/theme-spec#variants
750+
* @see https://theme-ui.com/components/variants
751+
* @see https://theme-ui.com/components/badge#variants
752+
*/
753+
badges?: Record<string, ThemeUIStyleObject>
754+
755+
/**
756+
* Alert variants can be defined in `theme.alerts`. The `Alert` component uses
757+
* `theme.alerts.primary` as its default variant.
758+
*
759+
* @see https://theme-ui.com/theme-spec#variants
760+
* @see https://theme-ui.com/components/variants
761+
* @see https://theme-ui.com/components/alert#variants
762+
*/
763+
alerts?: Record<string, ThemeUIStyleObject>
764+
765+
/**
766+
* Message variants can be defined in the `theme.messages` object.
767+
*
768+
* @see https://theme-ui.com/theme-spec#variants
769+
* @see https://theme-ui.com/components/variants
770+
* @see https://theme-ui.com/components/message#variants
771+
*/
772+
messages?: Record<string, ThemeUIStyleObject>
640773
}

packages/preset-sketchy/src/index.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import { Theme, ThemeUIStyleObject } from '@theme-ui/css'
22

3-
export interface ThemeSketchy extends Theme {
4-
cards: ThemeUIStyleObject
5-
links: ThemeUIStyleObject
6-
forms: Record<string, ThemeUIStyleObject>
7-
badges: ThemeUIStyleObject
8-
alerts: ThemeUIStyleObject
9-
messages: ThemeUIStyleObject
10-
}
11-
123
const defaultBorderStyles: ThemeUIStyleObject = {
134
border: 'thick',
145
color: 'text',
@@ -36,7 +27,7 @@ const formStyles: ThemeUIStyleObject = {
3627
},
3728
}
3829

39-
const theme: ThemeSketchy = {
30+
const theme: Theme = {
4031
colors: {
4132
text: '#000200',
4233
background: '#FAFAF9',
@@ -220,7 +211,6 @@ const theme: ThemeSketchy = {
220211
},
221212
},
222213
links: {
223-
color: 'primary',
224214
nav: {
225215
borderRadius: 'sketchy1',
226216
textDecoration: 'none',

0 commit comments

Comments
 (0)