|
| 1 | +import { styled } from 'stitches.config.js'; |
| 2 | + |
| 3 | +const Component = () => { |
| 4 | + return ( |
| 5 | + <Wrapper> |
| 6 | + <span className="main-text">Hover over me</span> |
| 7 | + <span className="hover-text">Hover over me</span> |
| 8 | + </Wrapper> |
| 9 | + ); |
| 10 | +}; |
| 11 | + |
| 12 | +const Wrapper = styled('a', { |
| 13 | + color: '$white', |
| 14 | + cursor: 'pointer', |
| 15 | + overflow: 'hidden', |
| 16 | + diplay: 'block', |
| 17 | + |
| 18 | + '.main-text': { |
| 19 | + diplay: 'block', |
| 20 | + transform: translateY(0), |
| 21 | + transition: 'transform 500ms' |
| 22 | + }, |
| 23 | + |
| 24 | + '&:before': { |
| 25 | + content: '', |
| 26 | + position: 'absolute', |
| 27 | + top: '50%', |
| 28 | + left: '50%', |
| 29 | + width: '140px', |
| 30 | + height: '140px', |
| 31 | + borderRadius: '50%', |
| 32 | + transform: 'translate3d(-50%,-50%,0) scale3d(0,0,0)', |
| 33 | + transition: 'opacity .4s cubic-bezier(.19,1,.22,1),transform .75s cubic-bezier(.19,1,.22,1)', |
| 34 | + backgroundColor: 'hsl(244, 63%, 69%)', |
| 35 | + opacity: 0 |
| 36 | + }, |
| 37 | + |
| 38 | + '&:hover': { |
| 39 | + '&:before': { |
| 40 | + opacity: 1, |
| 41 | + transitionDuration: '.85s', |
| 42 | + transform: 'translate3d(-50%,-50%,0) scale3d(1.2,1.2,1.2)' |
| 43 | + }, |
| 44 | + |
| 45 | + span: { |
| 46 | + color: '$white' |
| 47 | + } |
| 48 | + } |
| 49 | +}); |
| 50 | + |
| 51 | +const cssStyling = ` |
| 52 | +.exampleBtn { |
| 53 | + padding: 12px 24px; |
| 54 | + background-color: hsl(222, 100%, 95%); |
| 55 | + color: hsl(243, 80%, 62%); |
| 56 | + position: relative; |
| 57 | + border-radius: 6px; |
| 58 | + overflow: hidden; |
| 59 | + z-index: 1; |
| 60 | +} |
| 61 | +
|
| 62 | +.exampleBtn span { |
| 63 | + z-index: 1; |
| 64 | + position: relative; |
| 65 | +} |
| 66 | +
|
| 67 | +.exampleBtn::before { |
| 68 | + content: ''; |
| 69 | + position: absolute; |
| 70 | + top: 50%; |
| 71 | + left: 50%; |
| 72 | + width: 140px; |
| 73 | + height: 140px; |
| 74 | + border-radius: 50%; |
| 75 | + transform: translate3d(-50%,-50%,0) scale3d(0,0,0); |
| 76 | + transition: opacity .4s cubic-bezier(.19,1,.22,1),transform .75s cubic-bezier(.19,1,.22,1); |
| 77 | + background-color: hsl(243, 80%, 62%); |
| 78 | + opacity: 0; |
| 79 | +} |
| 80 | +
|
| 81 | +.exampleBtn:hover span { |
| 82 | + color: hsl(222, 100%, 95%); |
| 83 | +} |
| 84 | +
|
| 85 | +.exampleBtn:hover::before { |
| 86 | + opacity: 1; |
| 87 | + transition-duration: .85s; |
| 88 | + transform: translate3d(-50%,-50%,0) scale3d(1.2,1.2,1.2); |
| 89 | +} |
| 90 | +`; |
| 91 | + |
| 92 | +const scssStyling = ` |
| 93 | +.exampleBtn { |
| 94 | + padding: 12px 24px; |
| 95 | + background-color: hsl(222, 100%, 95%); |
| 96 | + color: hsl(243, 80%, 62%); |
| 97 | + position: relative; |
| 98 | + border-radius: 6px; |
| 99 | + overflow: hidden; |
| 100 | + z-index: 1; |
| 101 | +
|
| 102 | + span { |
| 103 | + z-index: 1; |
| 104 | + position: relative; |
| 105 | + } |
| 106 | +
|
| 107 | + &:before { |
| 108 | + content: ''; |
| 109 | + position: absolute; |
| 110 | + top: 50%; |
| 111 | + left: 50%; |
| 112 | + width: 140px; |
| 113 | + height: 140px; |
| 114 | + border-radius: 50%; |
| 115 | + transform: translate3d(-50%,-50%,0) scale3d(0,0,0); |
| 116 | + transition: opacity .4s cubic-bezier(.19,1,.22,1),transform .75s cubic-bezier(.19,1,.22,1); |
| 117 | + background-color: hsl(243, 80%, 62%); |
| 118 | + opacity: 0; |
| 119 | + } |
| 120 | +
|
| 121 | + &:hover { |
| 122 | + span { |
| 123 | + color: hsl(222, 100%, 95%); |
| 124 | + } |
| 125 | +
|
| 126 | + &:before { |
| 127 | + opacity: 1; |
| 128 | + transition-duration: .85s; |
| 129 | + transform: translate3d(-50%,-50%,0) scale3d(1.2,1.2,1.2); |
| 130 | + } |
| 131 | + } |
| 132 | +} |
| 133 | +`; |
| 134 | + |
| 135 | +export { cssStyling, scssStyling, Component }; |
0 commit comments