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

Allow users the ability to resize the logo #15093

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
69ad29a
adds settings to allow users to change logo size
mikesealey Nov 20, 2024
ebdf452
makes the currently-set value display in the logoSize dropdown
mikesealey Nov 20, 2024
1bd48e1
merge with master
mikesealey Nov 20, 2024
4baf3e0
wip adding option to display text under logo for large logos
mikesealey Nov 20, 2024
8a9490f
wip - need to work on unhappy paths
mikesealey Nov 21, 2024
82e3cf1
fixes text overflow
mikesealey Nov 22, 2024
21eac27
prevents overflow
mikesealey Nov 22, 2024
88c5b3b
wip
mikesealey Nov 22, 2024
dd06d5b
Merge branch 'master' of https://github.com/budibase/budibase into BU…
mikesealey Nov 26, 2024
a38d548
fixes alignment issue on first load
mikesealey Nov 28, 2024
fa62d9e
protects against oversize
mikesealey Nov 29, 2024
0da6cab
some fixes from our call
andz-bb Nov 29, 2024
e071fbc
wip
mikesealey Dec 3, 2024
bc7efe2
refators inline styling into classes
mikesealey Dec 4, 2024
c102ae9
merging master
mikesealey Dec 4, 2024
9f7f869
fixes resizing issue
mikesealey Dec 5, 2024
f4cb7d8
merge with master
mikesealey Dec 5, 2024
11073f9
Merge branch 'BUDI-8831b' of https://github.com/budibase/budibase int…
mikesealey Dec 5, 2024
56ee3bd
Merge branch 'master' of https://github.com/budibase/budibase into BU…
mikesealey Dec 5, 2024
b11270f
Merge branch 'master' into BUDI-8831b
mikesealey Dec 5, 2024
86c236d
corrections for lint checks
mikesealey Dec 5, 2024
48e94e8
Merge branch 'BUDI-8831b' of https://github.com/budibase/budibase int…
mikesealey Dec 5, 2024
b0252e3
fixes lint issue
mikesealey Dec 5, 2024
f45ce2d
yarn changes
mikesealey Dec 5, 2024
f05e0ce
Merge branch 'master' into BUDI-8831b
mikesealey Dec 5, 2024
10e03fc
Merge branch 'master' into BUDI-8831b
andz-bb Dec 9, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
{ value: "Right", barIcon: "TextAlignRight" },
]
const widthOptions = ["Max", "Large", "Medium", "Small"]
const logoSizeOptions = ["18", "24", "36", "48", "72", "96"]

$: bindings = getBindableProperties(
$selectedScreen,
Expand Down Expand Up @@ -121,15 +122,25 @@
updateOnChange: false,
}}
/>
<PropertyControl
label="Text align"
control={BarButtonList}
onChange={align => update("textAlign", align)}
value={$nav.textAlign}
props={{
options: alignmentOptions,
}}
/>
{#if (!$nav.textBelow && $nav.navigation === "Left") || $nav.navigation === "Top"}
<PropertyControl
label="Text align"
control={BarButtonList}
onChange={align => update("textAlign", align)}
value={$nav.textAlign}
props={{
options: alignmentOptions,
}}
/>
{/if}
{#if $nav.navigation !== "Top"}
<PropertyControl
label="Title below logo"
control={Checkbox}
onChange={textBelow => update("textBelow", textBelow)}
value={$nav.textBelow}
/>
{/if}
{/if}
<PropertyControl
label="Background"
Expand Down Expand Up @@ -171,6 +182,18 @@
updateOnChange: false,
}}
/>
<PropertyControl
label="Logo size (px)"
control={DrawerBindableCombobox}
value={$nav.logoSize}
onChange={logoSize => update("logoSize", logoSize)}
{bindings}
props={{
updateOnChange: true,
options: logoSizeOptions,
appendBindingsAsOptions: false,
}}
/>
<PropertyControl
label="Logo link URL"
control={DrawerBindableCombobox}
Expand Down
2 changes: 2 additions & 0 deletions packages/builder/src/stores/builder/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ export const INITIAL_NAVIGATION_STATE = {
title: null,
sticky: null,
hideLogo: null,
logoSize: "36",
logoUrl: null,
hideTitle: null,
textAlign: "Left",
textBelow: false,
navBackground: null,
navWidth: null,
navTextColor: null,
Expand Down
114 changes: 90 additions & 24 deletions packages/client/src/components/app/Layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
export let navWidth
export let pageWidth
export let logoLinkUrl
export let logoSize
export let openLogoLinkInNewTab
export let textAlign
export let textBelow
export let embedded = false

const NavigationClasses = {
Expand Down Expand Up @@ -196,6 +198,25 @@
return url
}

const getSanitizedLogoSize = logoSize => {
let sanitizedSize = 36

try {
const result = Function('"use strict"; return (' + logoSize + ")")()
if (typeof result === "number" && isFinite(result)) {
sanitizedSize = result
}
} catch (error) {
sanitizedSize = 36
}

if (sanitizedSize > 165) {
sanitizedSize = 165
}

return sanitizedSize + "px"
}

const handleClickLink = () => {
mobileOpen = false
sidePanelStore.actions.close()
Expand Down Expand Up @@ -242,28 +263,60 @@
/>
</div>
{/if}
<div class="logo">
{#if !hideLogo}
{#if logoLinkUrl && isInternal(logoLinkUrl) && !openLogoLinkInNewTab}
<a
href={getSanitizedUrl(logoLinkUrl, openLogoLinkInNewTab)}
use:linkable
>
<img src={logoUrl || "/builder/bblogo.png"} alt={title} />
</a>
{:else if logoLinkUrl}
<a
target={openLogoLinkInNewTab ? "_blank" : "_self"}
href={getSanitizedUrl(logoLinkUrl, openLogoLinkInNewTab)}
>
<img src={logoUrl || "/builder/bblogo.png"} alt={title} />
</a>
{:else}
<img src={logoUrl || "/builder/bblogo.png"} alt={title} />
<div
class="logo {navigation === 'Left'
? 'left-nav'
: ''} {navigation === 'Left' && textBelow
? 'text-below-left-nav'
: ''}"
style={navigation === "Top" && hideLogo ? "column-gap: 0;" : ""}
>
<div>
{#if !hideLogo}
{#if logoLinkUrl && isInternal(logoLinkUrl) && !openLogoLinkInNewTab}
<a
href={getSanitizedUrl(
logoLinkUrl,
openLogoLinkInNewTab
)}
use:linkable
>
<img
src={logoUrl || "/builder/bblogo.png"}
alt={title}
class="logo-image"
style="--logoSize: {getSanitizedLogoSize(logoSize)}"
/>
</a>
{:else if logoLinkUrl}
<a
target={openLogoLinkInNewTab ? "_blank" : "_self"}
href={getSanitizedUrl(
logoLinkUrl,
openLogoLinkInNewTab
)}
>
<img
src={logoUrl || "/builder/bblogo.png"}
alt={title}
class="logo-image"
style="--logoSize: {getSanitizedLogoSize(logoSize)}"
/>
</a>
{:else}
<img
src={logoUrl || "/builder/bblogo.png"}
alt={title}
class="logo-image"
style="--logoSize: {getSanitizedLogoSize(logoSize)}"
/>
{/if}
{/if}
{/if}
</div>
{#if !hideTitle && title}
<Heading size="S" {textAlign}>{title}</Heading>
<div id="heading">
<Heading size="S" {textAlign}>{title}</Heading>
</div>
{/if}
</div>
{#if !embedded}
Expand Down Expand Up @@ -517,20 +570,33 @@
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
gap: var(--spacing-m);
flex: 1 1 auto;
align-items: center;
}
.logo img {
height: 36px;
.logo-image {
max-width: var(--logoSize);
max-height: var(--logoSize);
}
.logo :global(h1) {
font-weight: 600;
flex: 1 1 auto;
width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
max-width: 100%;
}
#heading {
display: flex;
flex-grow: 1;
overflow: hidden;
max-width: 100%;
}
.left-nav {
max-width: 165px;
}
.text-below-left-nav {
flex-direction: column !important; /* Over-rides row setting in .logo*/
}
.portal {
display: grid;
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20612,6 +20612,11 @@ [email protected]:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.2.tgz#3169cf8c4c8a828cde53ba9ecb3d2b1d5dd67be6"
integrity sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==

[email protected]:
version "5.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.7.2.tgz#3169cf8c4c8a828cde53ba9ecb3d2b1d5dd67be6"
integrity sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==

"typescript@>=3 < 6":
version "5.5.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
Expand Down
Loading