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

Add new Alert variants #227

Merged
merged 2 commits into from
Sep 24, 2024
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
8 changes: 4 additions & 4 deletions styleguide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
"@types/react-modal": "^3.12.1",
"@types/react-table": "^7.7.1",
"@types/react-text-mask": "^5.4.8",
"autoprefixer": "^10.4.4",
"autoprefixer": "^10.4.20",
"babel-loader": "^8.2.2",
"babel-plugin-istanbul": "^6.1.1",
"babel-plugin-module-name-mapper": "^1.2.0",
Expand All @@ -108,7 +108,7 @@
"html-webpack-plugin": "^5.5.0",
"husky": "^5.1.3",
"identity-obj-proxy": "^3.0.0",
"postcss": "^8.4.31",
"postcss": "^8.4.47",
"postcss-loader": "^4.2.0",
"postcss-nesting": "^11.2.1",
"prettier": "^2.6.2",
Expand All @@ -120,7 +120,7 @@
"storybook-addon-designs": "^6.3.1",
"storybook-dark-mode": "^2.1.1",
"style-loader": "2.0.0",
"tailwindcss": "^3.1.2",
"tailwindcss": "^3.4.13",
"tsdx": "^0.14.1",
"tslib": "^2.4.0",
"typescript": "^4.6.4",
Expand All @@ -134,7 +134,7 @@
"tailwindcss": ">=3.1.0"
},
"dependencies": {
"@loja-integrada/tailwindcss-config": "^1.7.6",
"@loja-integrada/tailwindcss-config": "^2.0.3",
"@tippyjs/react": "^4.2.5",
"@types/react-select": "^4.0.17",
"babel-jest": "^29.2.2",
Expand Down
31 changes: 23 additions & 8 deletions styleguide/src/Indicators/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react'
import { Icon, IconProps } from '../../Icons'

type alertTypesOptions = 'success' | 'warning' | 'danger' | 'info' | 'primary'
type alertTypesOptions = 'success' | 'warning' | 'danger' | 'info' | 'infoOutline' | 'infoDark' | 'primary'

Check failure on line 4 in styleguide/src/Indicators/Alert/Alert.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 14.x and self-hosted

Replace `·'success'·|·'warning'·|·'danger'·|·'info'·|·'infoOutline'·|·'infoDark'` with `⏎··|·'success'⏎··|·'warning'⏎··|·'danger'⏎··|·'info'⏎··|·'infoOutline'⏎··|·'infoDark'⏎·`

const alertTypes: Record<
alertTypesOptions,
Expand All @@ -17,19 +17,29 @@
iconClass: 'text-success',
},
warning: {
class: 'bg-warning-light border-warning',
class: 'bg-warning-light border-warning-dark',
icon: 'exclamationTriangle',
iconClass: 'text-warning',
iconClass: 'text-warning-dark',
},
danger: {
class: 'bg-danger-light border-danger',
icon: 'ban',
iconClass: 'text-danger',
},
info: {
class: 'bg-base-1 border-inverted-2',
class: 'bg-focus-light border-focus-dark',
icon: 'infoCircle',
iconClass: 'text-inverted-2',
iconClass: 'text-focus-dark',
},
infoOutline: {
class: 'bg-base-1 border-focus-dark',
icon: 'infoCircle',
iconClass: 'text-focus-dark',
},
infoDark: {
class: 'bg-base-1 border-[#607081]',
icon: 'infoCircle',
iconClass: 'text-[#607081]',
},
primary: {
class: 'bg-primary-light border-primary',
Expand All @@ -47,6 +57,7 @@
showClose = false,
onClose,
hideIcon = false,
hideBorder = false,
customIcon,
}: AlertProps) => {
const [alertIsOpen, setAlertIsOpen] = useState(isOpen)
Expand All @@ -62,7 +73,7 @@
if (!alertIsOpen) return null
return (
<div
className={`alert border border-l-4 py-4 px-5 rounded w-full relative flex items-start sm:items-center ${alertTypes[type].class}`}
className={`alert border-l-4 py-4 pl-6 pr-5 rounded w-full relative flex items-start sm:items-center ${alertTypes[type].class}${hideBorder ? '' : ' border'}`}

Check failure on line 76 in styleguide/src/Indicators/Alert/Alert.tsx

View workflow job for this annotation

GitHub Actions / Build, lint, and test on Node 14.x and self-hosted

Replace `alertTypes[type].class` with `⏎········alertTypes[type].class⏎······`
>
{!hideIcon && (
<div
Expand All @@ -75,7 +86,7 @@
</div>
)}
<div className="flex-grow flex flex-col sm:flex-row items-start sm:items-center justify-between min-w-0">
<div className="flex flex-col justify-center min-w-0 break-words text-f6 tracking-4 leading-5 text-on-base">
<div className="flex flex-col justify-center min-w-0 break-words text-f6 tracking-4 leading-6 text-on-base">
<span className="alert-title font-semibold">{title}</span>
{subtitle && <span className="alert-subtitle mt-1">{subtitle}</span>}
</div>
Expand All @@ -86,7 +97,7 @@
)}
</div>
{(showClose || onClose) && (
<div className={`alert-close flex-shrink-0 flex ml-5`}>
<div className={`alert-close flex-shrink-0 flex self-start ml-5`}>
<button
className="p-2 -m-2 text-inverted-2 hover:text-inverted-1"
onClick={handleOnClose}
Expand Down Expand Up @@ -130,6 +141,10 @@
* @default false
*/
hideIcon?: boolean
/** Hide alert border
* @default false
*/
hideBorder?: boolean
/**
* Custom icon
*/
Expand Down
2 changes: 1 addition & 1 deletion styleguide/src/tailwind.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
@tailwind components;
@tailwind utilities;

@import '@loja-integrada/tailwindcss-config/src/_variables.scss';
@import '@loja-integrada/tailwindcss-config/styles/_variables.scss';

body {
@apply antialiased;
Expand Down
8 changes: 6 additions & 2 deletions styleguide/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
presets: [require('@loja-integrada/tailwindcss-config/src/variablePreset')],
import defaultPreset from '@loja-integrada/tailwindcss-config'

const config = {
presets: [defaultPreset],
content: ['./src/**/*.{js,ts,jsx,tsx}', './stories/**/*.{js,ts,jsx,tsx}'],
}

export default config
Loading
Loading