Skip to content

Commit fc9ffda

Browse files
committed
feat: make the connection details card more compact
1 parent 965bad4 commit fc9ffda

File tree

3 files changed

+84
-22
lines changed

3 files changed

+84
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { useState } from '@wordpress/element';
2+
import classnames from 'classnames';
3+
4+
export default function({ children, text }) {
5+
const [ isVisible, setIsVisible ] = useState( false );
6+
7+
if ( ! text ) {
8+
return children;
9+
}
10+
if ( ! children ) {
11+
return null;
12+
}
13+
14+
const classes = classnames(
15+
'absolute text-white bg-gray-800 text-xs p-2 rounded shadow-lg z-10 transition-opacity duration-200 pointer-events-none',
16+
{
17+
'opacity-100': isVisible,
18+
'opacity-0': ! isVisible
19+
}
20+
);
21+
22+
const tooltipStyles = {
23+
left: '50%',
24+
transform: 'translateX(-50%)',
25+
bottom: '120%'
26+
};
27+
28+
return (
29+
<div
30+
className="relative"
31+
onMouseEnter={() => setIsVisible( true )}
32+
onMouseLeave={() => setIsVisible( false )}
33+
>
34+
<div className={classes} style={tooltipStyles}>
35+
{text.charAt( 0 ).toUpperCase() + text.slice( 1 ).toLowerCase()}
36+
<div className="absolute -bottom-1 w-2 h-2 bg-gray-800" style={{ left: '50%', transform: 'translateX(-50%) rotate(45deg)' }}></div>
37+
</div>
38+
{children}
39+
</div>
40+
);
41+
}

assets/src/dashboard/parts/connected/Sidebar.js

+35-22
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { addQueryArgs } from '@wordpress/url';
1313

1414
import SPCRecommendation from './SPCRecommendation';
1515
import OptimizationStatus from './OptimizationStatus';
16+
import { globe, user } from '../../utils/icons';
17+
import Tooltip from '../components/Tooltip';
1618

1719
const reasons = [
1820
optimoleDashboardApp.strings.upgrade.reason_1,
@@ -47,31 +49,23 @@ const Sidebar = ({ settings }) => {
4749

4850
return (
4951
<div className="grid md:grid-cols-2 xl:flex xl:flex-col xl:mt-8 xl:mb-5 p-0 transition-all ease-in-out duration-700 gap-5 shrink-0 xl:w-[350px]">
50-
<div className="bg-white gap-5 flex flex-col text-gray-700 border-0 rounded-lg shadow-md p-8">
51-
<TextControl
52-
label={ optimoleDashboardApp.strings.logged_in_as }
53-
value={ name }
54-
className="optml__placeholder"
55-
disabled
56-
/>
57-
58-
<TextControl
59-
label={ optimoleDashboardApp.strings.private_cdn_url }
60-
value={ domain }
61-
className="optml__placeholder"
62-
disabled
63-
/>
52+
<div className="bg-white gap-3 flex flex-col text-gray-700 border-0 rounded-lg shadow-md p-8">
6453

65-
<hr className="m-0 border-grayish-blue"/>
54+
<div className="grid gap-4">
55+
<PlaceholderInput icon={user} value={name} tooltipText={optimoleDashboardApp.strings.logged_in_as}/>
56+
<PlaceholderInput icon={globe} value={domain} tooltipText={optimoleDashboardApp.strings.private_cdn_url}/>
57+
</div>
6658

67-
<p className="font-semibold text-xs text-light-black m-0">{ optimoleDashboardApp.strings.looking_for_api_key }</p>
59+
<hr className="m-0 border-t-grayish-blue"/>
6860

69-
<p
70-
className="m-0 -mt-3"
71-
dangerouslySetInnerHTML={ {
72-
__html: optimoleDashboardApp.strings.optml_dashboard
73-
} }
74-
/>
61+
<div className="border-t border-gray-300 block grid gap-2">
62+
<p className="font-semibold text-xs text-light-black m-0">{ optimoleDashboardApp.strings.looking_for_api_key }</p>
63+
<span
64+
dangerouslySetInnerHTML={ {
65+
__html: optimoleDashboardApp.strings.optml_dashboard
66+
} }
67+
/>
68+
</div>
7569
</div>
7670

7771
{ 'free' === plan ? (
@@ -137,3 +131,22 @@ const Sidebar = ({ settings }) => {
137131
};
138132

139133
export default Sidebar;
134+
135+
136+
const PlaceholderInput = ({ icon = null, value, tooltipText = '' }) => {
137+
return (
138+
<Tooltip text={tooltipText}>
139+
<div className="grid grid-cols-1 text-gray-700 hover:text-info transition-all ease-in-out duration-300">
140+
<input
141+
value={value}
142+
type="text"
143+
disabled
144+
className="col-start-1 row-start-1 block w-full rounded-md !bg-light-blue py-1.5 !pl-9 pr-3 !text-gray-500 !m-0 text-sm !py-0.5 !border-0"
145+
/>
146+
<span className="pointer-events-none col-start-1 row-start-1 flex items-center ml-3 w-4 h-4 self-center">
147+
{icon}
148+
</span>
149+
</div>
150+
</Tooltip>
151+
);
152+
};

assets/src/dashboard/utils/icons.js

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)