Skip to content

Commit

Permalink
Merge pull request #39 from Soare-Robert-Daniel/logo-size-slider
Browse files Browse the repository at this point in the history
Add a slider for changing the logo's size
  • Loading branch information
Soare-Robert-Daniel authored Apr 5, 2021
2 parents 46b504c + faeefe3 commit 8f0655b
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 10 deletions.
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"standard",
"prettier",
"prettier/@typescript-eslint",
"prettier/react",
"prettier/standard"
"prettier"
],
"rules": {
"react-hooks/rules-of-hooks": "error",
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.build
build
plugin_build
plugin_build/
web_modules
node_modules
package-lock.json
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"emmet.showAbbreviationSuggestions": false
"emmet.showAbbreviationSuggestions": false,
"editor.formatOnSave": true,
"vsintellicode.features.python.deepLearning": "enabled"
}
Binary file modified development/logo_maker_plugin.zip
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"react-color": "^2.19.3",
"react-dom": "^17.0.2",
"react-ga": "^3.3.0",
"react-range": "^1.8.7",
"react-router-dom": "^5.2.0",
"react-select": "^4.3.0",
"uuid": "^8.3.2"
Expand Down
2 changes: 1 addition & 1 deletion plugin_build/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-blocks', 'wp-i18n'), 'version' => 'a403e8cba0f53d92a2ebe57ed4fa2915');
<?php return array('dependencies' => array('react', 'wp-blocks', 'wp-i18n'), 'version' => '11d8a41369fd062bd2e1e7a26ad930c9');
2 changes: 1 addition & 1 deletion plugin_build/logo-maker.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => '42468e3f7249b847b516c0bcb82753e5');
<?php return array('dependencies' => array('react', 'react-dom'), 'version' => 'f64ee99e26b2eac9d17c8012291dd287');
2 changes: 1 addition & 1 deletion plugin_build/logo-maker.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions src/components/ui/SelectLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import * as React from "react"
import logos, { LogoSVGImport } from "../../assets/logos/index"
import LogoItem from "./LogoItem"
import store from "../../stores/UIStore"
import { Range } from "react-range"

/**
* This function will generate the `Select Logo Meniu` from design
*/
const SelectLogo: React.FunctionComponent<unknown> = () => {
const selectedLogoID = store.useState((s) => s.logo.src.id)
const scaleLogo = store.useState((s) => s.logo.scale) || 1.0

/**
* Updated logo source of the user interface store
Expand All @@ -20,6 +22,12 @@ const SelectLogo: React.FunctionComponent<unknown> = () => {
})
}

const setScale = (value: number) => {
store.update((s) => {
s.logo.scale = value
})
}

/**
* Render the logos for the menu
*/
Expand All @@ -32,6 +40,77 @@ const SelectLogo: React.FunctionComponent<unknown> = () => {
return (
<div className="select-logo">
<h1>{`LOGO OPTIONS (${logos.length})`}</h1>
<p>Select the scale</p>
<div
style={{
display: "flex",
justifyContent: "center",
alignItems: "center",
flexWrap: "wrap",
height: "75px",
}}
>
<Range
step={0.1}
min={0.5}
max={2.0}
values={[scaleLogo]}
onChange={(values) => setScale(values.pop() || 1)}
renderTrack={({ props, children }) => (
<div
{...props}
style={{
...props.style,
height: "6px",
width: "90%",
backgroundColor: "#ccc",
}}
>
{children}
</div>
)}
renderThumb={({ props, isDragged }) => (
<div
{...props}
style={{
...props.style,
height: "42px",
width: "42px",
borderRadius: "4px",
backgroundColor: "#FFF",
display: "flex",
justifyContent: "center",
alignItems: "center",
boxShadow: "0px 2px 6px #AAA",
}}
>
<div
style={{
position: "absolute",
top: "-28px",
color: "#fff",
fontWeight: "bold",
fontSize: "14px",
fontFamily: "Arial,Helvetica Neue,Helvetica,sans-serif",
padding: "4px",
borderRadius: "4px",
backgroundColor: "#548BF4",
}}
>
{`${scaleLogo.toFixed(1)}x`}
</div>
<div
style={{
height: "16px",
width: "5px",
backgroundColor: isDragged ? "#548BF4" : "#CCC",
}}
/>
</div>
)}
/>
</div>

<p>Select a symbol for the logo</p>
<div
className="logo-list"
Expand Down
2 changes: 1 addition & 1 deletion src/engine/render/shapesBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function buildDefaultShapes(parent: Svg, componentsProps: LogoProps, font

// Apply other properties
logo.viewbox(0, 0, logo.bbox().width, logo.bbox().height + 5)
.size(pLogo.width, pLogo.height)
.size(pLogo.width * pLogo.scale, pLogo.height * pLogo.scale)
.css("fill", pLogo.style.fill);

if( (title as Text).font !== undefined ) {
Expand Down
3 changes: 3 additions & 0 deletions src/stores/UIStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export type TLogo = {
style: {
fill: string
}
/** Scale */
scale: number
}

/** The title props */
Expand Down Expand Up @@ -100,6 +102,7 @@ export const UIStore = new Store<StoreProps>(
style: {
fill: "#FFFFFF",
},
scale: 1
},

title: {
Expand Down

0 comments on commit 8f0655b

Please sign in to comment.