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

Better Callouts #185

Merged
merged 1 commit into from
Jul 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/nextra-theme-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build:tailwind": "NODE_ENV=production yarn postcss src/styles.css -o style.css --verbose",
"build:layout": "NODE_ENV=production microbundle src/*.js -f cjs -o dist --no-sourcemap --jsx React.createElement --target node",
"dev:layout": "microbundle watch src/*.js -f cjs -o dist --no-sourcemap --jsx React.createElement --target node",
"dev:tailwind": "yarn postcss src/styles.css -o style.css -w --verbose"
"dev:tailwind": "TAILWIND_MODE=watch yarn postcss src/styles.css -o style.css -w --verbose"
},
"dependencies": {
"@mdx-js/react": "^1.6.16",
Expand Down Expand Up @@ -48,6 +48,6 @@
"microbundle": "^0.12.4",
"postcss": "^8.2.1",
"postcss-cli": "^8.3.0",
"tailwindcss": "^2.0.1"
"tailwindcss": "^2.2.4"
}
}
27 changes: 17 additions & 10 deletions packages/nextra-theme-docs/src/callout.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import React from 'react'

// https://www.notion.so/Callout-blocks-5b2638247b54447eb2e21145f97194b0
export default ({
children,
background = 'bg-orange-100 dark:text-gray-800',
emoji = '💡'
}) => {
const themes = {
default:
'bg-orange-100 text-orange-800 dark:text-orange-300 dark:bg-orange-200 dark:bg-opacity-10',
error:
'bg-red-200 text-red-900 dark:text-red-200 dark:bg-red-600 dark:bg-opacity-30',
warning:
'bg-yellow-200 text-yellow-900 dark:text-yellow-200 dark:bg-yellow-700 dark:bg-opacity-30'
}

export default ({ children, type = 'default', emoji = '💡' }) => {
return (
<div className={`${background} flex rounded-lg callout mt-6`}>
<div className="pl-3 pr-2 py-2 select-none text-xl" style={{
fontFamily: '"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
}}>
<div className={`${themes[type]} flex rounded-lg callout mt-6`}>
<div
className="pl-3 pr-2 py-2 select-none text-xl"
style={{
fontFamily: '"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
}}
>
{emoji}
</div>
<div className="pr-4 py-2">{children}</div>
Expand Down
1 change: 1 addition & 0 deletions packages/nextra-theme-docs/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
mode: 'jit',
purge: ['./src/**/*.js', './src/**/*.css'],
theme: {
screens: {
Expand Down
Loading