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

Introduce html-based AboutGuide. Normalize dialogs. Use theme. #531

Merged
merged 32 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
171fe7f
Introduce html-based AboutGuide. Normalize dialogs: rely more on mui…
pablo-mayrgundter Dec 23, 2022
f48e517
Use open icon for open dialog header. Use theme highlight.secondary …
pablo-mayrgundter Dec 23, 2022
dc78456
Add screenshot of 3d buildings logo in public for AboutGuide.
pablo-mayrgundter Dec 23, 2022
d7b7f63
Use GlobalStyles for svg sizing, fill and small control icon sizing. …
pablo-mayrgundter Dec 24, 2022
397aa89
Restore theme colors to LogoB.
pablo-mayrgundter Dec 24, 2022
7ad1b7d
merge.
pablo-mayrgundter Dec 28, 2022
cca1fa1
Cherrypick merge fix.
pablo-mayrgundter Dec 28, 2022
9bcf6c3
Lots of color normalization.
pablo-mayrgundter Dec 28, 2022
42838ed
Use more of Mui Card components for notes.
pablo-mayrgundter Dec 28, 2022
0e0fdca
style open dialog and about dialog
OlegMoshkovich Jan 6, 2023
5e5893b
work in progress
OlegMoshkovich Jan 7, 2023
ddc482c
tuned the theme
OlegMoshkovich Jan 7, 2023
f87e595
adjusted note card
OlegMoshkovich Jan 7, 2023
e23365e
notecard border
OlegMoshkovich Jan 7, 2023
fc415db
subtract scroll bar from sidedrawer
OlegMoshkovich Jan 7, 2023
6334e70
control icons
OlegMoshkovich Jan 7, 2023
beaab3d
adjust control icons
OlegMoshkovich Jan 7, 2023
c947ca3
theme, fixed paths to models
OlegMoshkovich Jan 7, 2023
fece42c
colors and toggle
OlegMoshkovich Jan 7, 2023
d3832ea
adjust the guide
OlegMoshkovich Jan 9, 2023
763f026
about guide and colors
OlegMoshkovich Jan 10, 2023
cf44590
snackbar message
OlegMoshkovich Jan 11, 2023
41416bb
merge
pablo-mayrgundter Jan 27, 2023
f18b8c4
fixes
pablo-mayrgundter Jan 31, 2023
42d19f4
Delete #index.css#
pablo-mayrgundter Feb 1, 2023
d07189b
Refactor drawer. Desktop working nicely
pablo-mayrgundter Feb 1, 2023
3a4ee38
Merge remote-tracking branch 'origin/about' into about
pablo-mayrgundter Feb 1, 2023
994d114
Refactor drawer. Mobile working again.
pablo-mayrgundter Feb 1, 2023
f824f32
Oleg changes to About.
pablo-mayrgundter Feb 1, 2023
b7f0fbc
Merge branch 'main' into about
pablo-mayrgundter Feb 2, 2023
e93fc67
Oleg comments.
pablo-mayrgundter Feb 2, 2023
b9579e6
Fix broken homepage e2e test, remove unused old copy of Components/Ab…
pablo-mayrgundter Feb 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const buildDir = path.resolve(__dirname, '..', 'docs')
export const build = {
entryPoints: [entryPoint],
bundle: true,
minify: process.env.NODE_ENV === 'production',
minify: false, // process.env.NODE_ENV === 'production',
// https://esbuild.github.io/api/#keep-names
// We use code identifiers e.g. in ItemProperties for their names
keepNames: true,
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bldrs",
"version": "1.0.0-r584",
"version": "1.0.0-r593",
"main": "src/index.jsx",
"license": "MIT",
"homepage": "https://github.com/bldrs-ai/Share",
Expand Down Expand Up @@ -57,6 +57,7 @@
"@babel/preset-env": "^7.18.10",
"@babel/preset-react": "^7.18.6",
"@bahmutov/cypress-esbuild-preprocessor": "^2.1.3",
"@mui/types": "^7.2.3",
"@pablo-mayrgundter/cookies.js": "^1.0.0",
"@storybook/addon-actions": "^6.5.10",
"@storybook/addon-essentials": "^6.5.10",
Expand Down
27 changes: 0 additions & 27 deletions public/index.css

This file was deleted.

3 changes: 1 addition & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&amp;display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400&amp;display=swap" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600&display=swap"
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600&amp;display=swap"
rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="stylesheet" href="./index.css">

<!-- Global site tag (gtag.js) - Google Analytics snippet -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-210924287-3"></script>
Expand Down
Binary file added public/logo-buildings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added src/#index.css#
Empty file.
87 changes: 87 additions & 0 deletions src/Components/About/AboutControl.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React, {useState} from 'react'
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'
import {getCookieBoolean, setCookieBoolean} from '../../privacy/Privacy'
import Dialog from '../Dialog'
import {ControlButton} from '../Buttons'
import AboutGuide from './AboutGuide'
import PrivacyControl from './PrivacyControl'
import AboutIcon from '../../assets/2D_Icons/Information.svg'
import LogoB from '../../assets/LogoB_3.svg'


/**
* Button to toggle About panel on and off
*
* @return {React.ReactElement}
*/
export default function AboutControl() {
const [isDialogDisplayed, setIsDialogDisplayed] = useState(getCookieBoolean({
component: 'about',
name: 'isFirstTime',
defaultValue: true,
}))


return (
<ControlButton
title='About BLDRS'
isDialogDisplayed={isDialogDisplayed}
setIsDialogDisplayed={setIsDialogDisplayed}
icon={<AboutIcon/>}
dialog={
<AboutDialog
isDialogDisplayed={isDialogDisplayed}
setIsDialogDisplayed={() => {
setIsDialogDisplayed(false)
setCookieBoolean({component: 'about', name: 'isFirstTime', value: false})
}}
/>
}
/>
)
}


/**
* The AboutDialog component
*
* @param {boolean} isDialogDisplayed
* @param {Function} setIsDialogDisplayed
* @return {React.Component} React component
*/
function AboutDialog({isDialogDisplayed, setIsDialogDisplayed}) {
return (
<Dialog
icon={
<Box sx={{display: 'inline-flex', flexDirection: 'column', textAlign: 'center'}}>
<LogoB style={{width: '80px', height: '80px'}}/>
bldrs.ai
</Box>
}
headerText={''}
isDialogDisplayed={isDialogDisplayed}
setIsDialogDisplayed={setIsDialogDisplayed}
content={<AboutContent/>}
actionTitle='OK'
actionCb={() => setIsDialogDisplayed(false)}
/>)
}


/**
* The content portion of the AboutDialog
*
* @return {React.ReactElement} React component
*/
function AboutContent() {
return (
<Box>
<Typography variant='h1' gutterBottom={true}>Build Every Thing Together</Typography>
<a href='https://github.com/bldrs-ai/Share' target='_new'>
github.com/bldrs-ai/Share
</a>
<AboutGuide/>
<PrivacyControl/>
</Box>)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react'
import {render, fireEvent} from '@testing-library/react'
import * as Privacy from '../privacy/Privacy'
import {MockComponent} from '../__mocks__/MockComponent'
import {MockComponent} from '../../__mocks__/MockComponent'
import AboutControl from './AboutControl'
import {setPrivacy} from './AboutControl'


describe('About control tests', () => {
Expand All @@ -20,13 +18,4 @@ describe('About control tests', () => {
const dialogTitle = getByText('Build Every Thing Together')
expect(dialogTitle).toBeInTheDocument()
})

test('sets privacy settings correctly', () => {
// Test setting privacy to disabled
setPrivacy(true)
expect(Privacy.isPrivacySocialEnabled()).toBe(false)
// Test setting privacy to enabled
setPrivacy(false)
expect(Privacy.isPrivacySocialEnabled()).toBe(true)
})
})
67 changes: 67 additions & 0 deletions src/Components/About/AboutGuide.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import React, {useContext} from 'react'
import Box from '@mui/material/Box'
import {useTheme} from '@mui/styles'
import {ColorModeContext} from '../../Context/ColorMode'
import CutPlaneIcon from '../../assets/2D_Icons/CutPlane.svg'
import ListIcon from '../../assets/2D_Icons/List.svg'
import NotesIcon from '../../assets/2D_Icons/Notes.svg'
import ShareIcon from '../../assets/2D_Icons/Share.svg'


/**
* A miniature view of the App to show as a guide in the About dialog.
*
* @return {React.ReactElement}
*/
export default function AboutGuide() {
const theme = useTheme()
const colorMode = useContext(ColorModeContext)
return (
<Box
sx={{
width: '250px',
height: '150px',
fontSize: '0.8em',
borderRadius: '5px',
opacity: .8,
margin: '2em 0',
padding: '0.5em',
color: theme.palette.primary.contrastText,
backgroundColor: colorMode.isDay() ? '#E8E8E8' : '#4C4C4C',
}}
>
<Box
sx={{
'float': 'right',
'& svg': {
width: '12px',
height: '12px',
verticalAlign: 'middle',
lineHeight: '15px',
fill: theme.palette.primary.contrastText,
},
'& div': {
textAlign: 'right',
verticalAlign: 'middle',
whiteSpace: 'nowrap',
lineHeight: '15px',
},
}}
>
<div>Share model → <ShareIcon/></div>
<div>Collaborate with Notes → <NotesIcon/></div>
<div>View model item properties → <ListIcon/></div>
<div>Section and Plan views → <CutPlaneIcon/></div>
</Box>
<img
src='/logo-buildings.png'
alt='logo'
width='100'
style={{
margin: '0 auto',
opacity: 0.5,
}}
/>
</Box>
)
}
61 changes: 61 additions & 0 deletions src/Components/About/PrivacyControl.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React, {useEffect, useState} from 'react'
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'
import * as Privacy from '../../privacy/Privacy'
import Toggle from '../Toggle'


/**
* The PrivacyControl component contains and "accept cookies" checkbox.
*
* @return {React.ReactElement}
*/
export default function PrivacyControl() {
const [acceptCookies, setAcceptCookies] = useState(true)


useEffect(() => {
if (Privacy.isPrivacySocialEnabled()) {
setAcceptCookies(true)
} else {
setAcceptCookies(false)
}
}, [])

const changePrivacy = () => {
setPrivacy(acceptCookies)
setAcceptCookies(!acceptCookies)
}


return (
<Box
sx={{
width: '100%',
margin: '1em 0',
textAlign: 'justify',
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<Typography>
Analytics cookies<br/>
<a href='https://github.com/bldrs-ai/Share/wiki/Design#privacy' target='_new'>
read more
</a>
</Typography>
<Toggle checked={acceptCookies} onChange={changePrivacy}/>
</Box>
)
}


export const setPrivacy = (acceptCookies) => {
if (acceptCookies) {
Privacy.setUsageAndSocialEnabled(false, false)
} else {
Privacy.setUsageAndSocialEnabled(true, true)
}
}
14 changes: 14 additions & 0 deletions src/Components/About/PrivacyControl.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import * as Privacy from '../../privacy/Privacy'
import {setPrivacy} from './PrivacyControl'


describe('PrivacyControl tests', () => {
test('sets privacy settings correctly', () => {
// Test setting privacy to disabled
setPrivacy(true)
expect(Privacy.isPrivacySocialEnabled()).toBe(false)
// Test setting privacy to enabled
setPrivacy(false)
expect(Privacy.isPrivacySocialEnabled()).toBe(true)
})
})