|
| 1 | +# Notes for context api |
| 2 | + |
| 3 | +## ThemeBtn UI |
| 4 | + |
| 5 | +```javascript |
| 6 | +export default function ThemeBtn() { |
| 7 | + |
| 8 | + |
| 9 | + return ( |
| 10 | + <label className="relative inline-flex items-center cursor-pointer"> |
| 11 | + <input |
| 12 | + type="checkbox" |
| 13 | + value="" |
| 14 | + className="sr-only peer" |
| 15 | + /> |
| 16 | + <div className="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"></div> |
| 17 | + <span className="ml-3 text-sm font-medium text-gray-900">Toggle Theme</span> |
| 18 | + </label> |
| 19 | + ); |
| 20 | +} |
| 21 | + |
| 22 | + |
| 23 | +``` |
| 24 | + |
| 25 | +## Card UI |
| 26 | + |
| 27 | +```javascript |
| 28 | +export default function Card() { |
| 29 | + return ( |
| 30 | + <div className="w-full bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700"> |
| 31 | + <a href="/"> |
| 32 | + <img className="p-8 rounded-t-lg" src="https://images.pexels.com/photos/18264716/pexels-photo-18264716/free-photo-of-man-people-laptop-internet.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2" alt="product_image1" /> |
| 33 | + </a> |
| 34 | + <div className="px-5 pb-5"> |
| 35 | + <a href="/"> |
| 36 | + <h5 className="text-xl font-semibold tracking-tight text-gray-900 dark:text-white"> |
| 37 | + Apple Watch Series 7 GPS, Aluminium Case, Starlight Sport |
| 38 | + </h5> |
| 39 | + </a> |
| 40 | + <div className="flex items-center mt-2.5 mb-5"> |
| 41 | + <svg |
| 42 | + className="w-4 h-4 text-yellow-300 mr-1" |
| 43 | + aria-hidden="true" |
| 44 | + xmlns="http://www.w3.org/2000/svg" |
| 45 | + fill="currentColor" |
| 46 | + viewBox="0 0 22 20" |
| 47 | + > |
| 48 | + <path d="M20.924 7.625a1.523 1.523 0 0 0-1.238-1.044l-5.051-.734-2.259-4.577a1.534 1.534 0 0 0-2.752 0L7.365 5.847l-5.051.734A1.535 1.535 0 0 0 1.463 9.2l3.656 3.563-.863 5.031a1.532 1.532 0 0 0 2.226 1.616L11 17.033l4.518 2.375a1.534 1.534 0 0 0 2.226-1.617l-.863-5.03L20.537 9.2a1.523 1.523 0 0 0 .387-1.575Z" /> |
| 49 | + </svg> |
| 50 | + <svg |
| 51 | + className="w-4 h-4 text-yellow-300 mr-1" |
| 52 | + aria-hidden="true" |
| 53 | + xmlns="http://www.w3.org/2000/svg" |
| 54 | + fill="currentColor" |
| 55 | + viewBox="0 0 22 20" |
| 56 | + > |
| 57 | + <path d="M20.924 7.625a1.523 1.523 0 0 0-1.238-1.044l-5.051-.734-2.259-4.577a1.534 1.534 0 0 0-2.752 0L7.365 5.847l-5.051.734A1.535 1.535 0 0 0 1.463 9.2l3.656 3.563-.863 5.031a1.532 1.532 0 0 0 2.226 1.616L11 17.033l4.518 2.375a1.534 1.534 0 0 0 2.226-1.617l-.863-5.03L20.537 9.2a1.523 1.523 0 0 0 .387-1.575Z" /> |
| 58 | + </svg> |
| 59 | + <svg |
| 60 | + className="w-4 h-4 text-yellow-300 mr-1" |
| 61 | + aria-hidden="true" |
| 62 | + xmlns="http://www.w3.org/2000/svg" |
| 63 | + fill="currentColor" |
| 64 | + viewBox="0 0 22 20" |
| 65 | + > |
| 66 | + <path d="M20.924 7.625a1.523 1.523 0 0 0-1.238-1.044l-5.051-.734-2.259-4.577a1.534 1.534 0 0 0-2.752 0L7.365 5.847l-5.051.734A1.535 1.535 0 0 0 1.463 9.2l3.656 3.563-.863 5.031a1.532 1.532 0 0 0 2.226 1.616L11 17.033l4.518 2.375a1.534 1.534 0 0 0 2.226-1.617l-.863-5.03L20.537 9.2a1.523 1.523 0 0 0 .387-1.575Z" /> |
| 67 | + </svg> |
| 68 | + <svg |
| 69 | + className="w-4 h-4 text-yellow-300 mr-1" |
| 70 | + aria-hidden="true" |
| 71 | + xmlns="http://www.w3.org/2000/svg" |
| 72 | + fill="currentColor" |
| 73 | + viewBox="0 0 22 20" |
| 74 | + > |
| 75 | + <path d="M20.924 7.625a1.523 1.523 0 0 0-1.238-1.044l-5.051-.734-2.259-4.577a1.534 1.534 0 0 0-2.752 0L7.365 5.847l-5.051.734A1.535 1.535 0 0 0 1.463 9.2l3.656 3.563-.863 5.031a1.532 1.532 0 0 0 2.226 1.616L11 17.033l4.518 2.375a1.534 1.534 0 0 0 2.226-1.617l-.863-5.03L20.537 9.2a1.523 1.523 0 0 0 .387-1.575Z" /> |
| 76 | + </svg> |
| 77 | + <svg |
| 78 | + className="w-4 h-4 text-gray-200 dark:text-gray-600" |
| 79 | + aria-hidden="true" |
| 80 | + xmlns="http://www.w3.org/2000/svg" |
| 81 | + fill="currentColor" |
| 82 | + viewBox="0 0 22 20" |
| 83 | + > |
| 84 | + <path d="M20.924 7.625a1.523 1.523 0 0 0-1.238-1.044l-5.051-.734-2.259-4.577a1.534 1.534 0 0 0-2.752 0L7.365 5.847l-5.051.734A1.535 1.535 0 0 0 1.463 9.2l3.656 3.563-.863 5.031a1.532 1.532 0 0 0 2.226 1.616L11 17.033l4.518 2.375a1.534 1.534 0 0 0 2.226-1.617l-.863-5.03L20.537 9.2a1.523 1.523 0 0 0 .387-1.575Z" /> |
| 85 | + </svg> |
| 86 | + <span className="bg-blue-100 text-blue-800 text-xs font-semibold mr-2 px-2.5 py-0.5 rounded dark:bg-blue-200 dark:text-blue-800 ml-3"> |
| 87 | + 4.0 |
| 88 | + </span> |
| 89 | + </div> |
| 90 | + <div className="flex items-center justify-between"> |
| 91 | + <span className="text-3xl font-bold text-gray-900 dark:text-white">$599</span> |
| 92 | + <a |
| 93 | + href="/" |
| 94 | + className="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800" |
| 95 | + > |
| 96 | + Add to cart |
| 97 | + </a> |
| 98 | + </div> |
| 99 | + </div> |
| 100 | + </div> |
| 101 | + ); |
| 102 | +} |
| 103 | + |
| 104 | +``` |
| 105 | +## App UI |
| 106 | + |
| 107 | +```javascript |
| 108 | + |
| 109 | +<div className="flex flex-wrap min-h-screen items-center"> |
| 110 | + <div className="w-full"> |
| 111 | + <div className="w-full max-w-sm mx-auto flex justify-end mb-4"> |
| 112 | + |
| 113 | + </div> |
| 114 | + |
| 115 | + <div className="w-full max-w-sm mx-auto"> |
| 116 | + |
| 117 | + </div> |
| 118 | + </div> |
| 119 | + </div> |
| 120 | + |
| 121 | +``` |
| 122 | + |
| 123 | +## remember to change config in tailwind |
| 124 | + |
| 125 | +```javascript |
| 126 | +/** @type {import('tailwindcss').Config} */ |
| 127 | +export default { |
| 128 | + content: [ |
| 129 | + "./index.html", |
| 130 | + "./src/**/*.{js,ts,jsx,tsx}", |
| 131 | + ], |
| 132 | + darkMode: "class", |
| 133 | + theme: { |
| 134 | + extend: {}, |
| 135 | + }, |
| 136 | + plugins: [], |
| 137 | +} |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | +``` |
| 143 | + |
0 commit comments