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

Multiple new settings, app components import, multiple format exports, static folder, ... #128

Merged
merged 12 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 10 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
220 changes: 213 additions & 7 deletions package-lock.json

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

18 changes: 18 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added

- Support to import custom `SideBar` component in `app/` folder that replaces sidebar in Mechanic UI.
- New design function export `ExtraUi`, expected to be a React component that's added to the bottom section of sidebar, on top of default toggles and buttons.
- Support for SVG and PNG exports for SVG based engines like `engine-react` and `engine-svg`.
- New `hideFeedback` design function setting. When true, Mechanic's feedback button is hidden. Defaults to false.
- New `hideNavigation` design function setting. When true, the navigation input that let's users select a design function is hidden. Defaults to false.
fdoflorenzano marked this conversation as resolved.
Show resolved Hide resolved
- New `hidePresets` design function setting. When true, preset selection input is hidden. Defaults to false.
fdoflorenzano marked this conversation as resolved.
Show resolved Hide resolved
- New `hideScaleToFit` design function setting. When true, Scale to Fit toggle is hidden. Defaults to false.
- New `scaleToFit` design function setting. When false, Scale to Fit will be off initially. Defaults to true.
fdoflorenzano marked this conversation as resolved.
Show resolved Hide resolved
- New `hideAutoRefresh` design function setting. When true, Auto Refresh toggle is hidden. Defaults to false.
- New `autoRefresh` design function setting. When false, Auto Refresh will be off initially. Defaults to true.
fdoflorenzano marked this conversation as resolved.
Show resolved Hide resolved
- New `hideGenerate` design function setting. When true, Generate button is hidden. Defaults to false.
- New `showMultipleExports` design function setting. When false, single export button is shown. When true, two separate export buttons are shown: one for PNG export and another for SVG export. Defaults to false.
- New `ignoreStyles` design function setting. When true, CSS in iframe is injected into design function's SVG output. Defaults to false.
- Support to serve `static/` folder for all design functions.
- `_isPreview` value is passed to design function handler in `inputs` argument.
fdoflorenzano marked this conversation as resolved.
Show resolved Hide resolved

### Changed

- Changed filename from `[name][timestamp].[ext]` to `[filename]-[timestamp].[ext]` for better readability
Expand Down
Empty file added packages/core/app/APP
Empty file.
7 changes: 5 additions & 2 deletions packages/core/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@ import functions from "./FUNCTIONS";
import * as css from "./App.module.css";

const Layout = ({ funcName, functions, mainRef, iframeRef }) => {
const { settings } = functions[funcName];
return (
<div className={css.root}>
{!settings.hideFeedback && (
<Feedback href="https://forms.gle/uBTn8oVThZHVghV89">Got feedback?</Feedback>
)}
<SideBar name={funcName} exports={functions[funcName]} iframe={iframeRef} mainRef={mainRef}>
<Nav name={funcName} functions={functions} />
{!settings.hideNavigation && <Nav name={funcName} functions={functions} />}
</SideBar>
<main className={css.main} ref={mainRef}>
<iframe
Expand All @@ -34,7 +38,6 @@ const AppComponent = () => {
const firstFunctionName = Object.keys(functions)[0];
return (
<div className={css.base}>
<Feedback href="https://forms.gle/uBTn8oVThZHVghV89">Got feedback?</Feedback>
<Switch>
{Object.keys(functions).map((name, i) => (
<Route
Expand Down
13 changes: 13 additions & 0 deletions packages/core/app/app-components-loader.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const path = require("path");
const { getOptions } = require("loader-utils");

module.exports = function () {
const { appCompsPath } = getOptions(this);

const result = `
import * as components from "${appCompsPath.split(path.sep).join("/")}";
export const appComponents = components;
`;
// console.log(result);
return result;
};
Loading