|
| 1 | +import { styled } from 'stitches.config.js'; |
| 2 | + |
| 3 | +const Component = () => { |
| 4 | + return <Wrapper>Hover over me</Wrapper>; |
| 5 | +}; |
| 6 | + |
| 7 | +const Wrapper = styled('a', { |
| 8 | + overflow: 'hidden', |
| 9 | + padding: '12px 24px', |
| 10 | + borderRadius: '$1', |
| 11 | + background: 'linear-gradient(to top, hsl(260deg 80% 40%), hsl(260deg 80% 50%))', |
| 12 | + color: '$white', |
| 13 | + transition: 'filter 600ms', |
| 14 | + cursor: 'pointer', |
| 15 | + |
| 16 | + '&:hover, &:focus': { |
| 17 | + transition: 'filter 250ms', |
| 18 | + filter: 'brightness(110%) hue-rotate(60deg)' |
| 19 | + } |
| 20 | +}); |
| 21 | + |
| 22 | +const cssStyling = ` |
| 23 | +.exampleClass { |
| 24 | + overflow: hidden; |
| 25 | + padding: 12px 24px; |
| 26 | + border-radius: 7px; |
| 27 | + background-color: white; |
| 28 | + color: black; |
| 29 | + position: relative; |
| 30 | + display: inline-block; |
| 31 | + cursor: pointer; |
| 32 | +} |
| 33 | +
|
| 34 | +.exampleClass span { |
| 35 | + position: relative; |
| 36 | + transition: color 0.6s cubic-bezier(0.53, 0.21, 0, 1); |
| 37 | +}, |
| 38 | +
|
| 39 | +.exampleClass:before { |
| 40 | + content: ""; |
| 41 | + display: block; |
| 42 | + position: absolute; |
| 43 | + top: 0; |
| 44 | + left: 0; |
| 45 | + width: 100%; |
| 46 | + height: 100%; |
| 47 | + background: hsl(244, 63%, 69%); |
| 48 | + transform: scaleX(0); |
| 49 | + transform-origin: 100% 100%; |
| 50 | + transition: transform 0.6s cubic-bezier(0.53, 0.21, 0, 1); |
| 51 | +}, |
| 52 | +
|
| 53 | +.exampleClass:hover::before { |
| 54 | + transform-origin: 0 0; |
| 55 | + transform: scaleX(1); |
| 56 | +}, |
| 57 | +
|
| 58 | +.exampleClass:hover span { |
| 59 | + color: white; |
| 60 | +}, |
| 61 | +`; |
| 62 | + |
| 63 | +const scssStyling = ` |
| 64 | +.exampleClass { |
| 65 | + overflow: hidden; |
| 66 | + padding: 12px 24px; |
| 67 | + border-radius: 7px; |
| 68 | + background-color: white; |
| 69 | + color: black; |
| 70 | + position: relative; |
| 71 | + display: inline-block; |
| 72 | + cursor: pointer; |
| 73 | +
|
| 74 | + span { |
| 75 | + position: relative; |
| 76 | + transition: color 0.6s cubic-bezier(0.53, 0.21, 0, 1); |
| 77 | + } |
| 78 | +
|
| 79 | + &:before { |
| 80 | + content: ""; |
| 81 | + display: block; |
| 82 | + position: absolute; |
| 83 | + top: 0; |
| 84 | + left: 0; |
| 85 | + width: 100%; |
| 86 | + height: 100%; |
| 87 | + background: hsl(244, 63%, 69%); |
| 88 | + transform: scaleX(0); |
| 89 | + transform-origin: 100% 100%; |
| 90 | + transition: transform 0.6s cubic-bezier(0.53, 0.21, 0, 1); |
| 91 | + } |
| 92 | +
|
| 93 | + &:hover { |
| 94 | + &:before { |
| 95 | + transform-origin: 0 0; |
| 96 | + transform: scaleX(1); |
| 97 | + } |
| 98 | +
|
| 99 | + span { |
| 100 | + color: white; |
| 101 | + } |
| 102 | + } |
| 103 | +} |
| 104 | +`; |
| 105 | + |
| 106 | +export { cssStyling, scssStyling, Component }; |
0 commit comments