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

migrate element card to handle 3 states #127

Open
joshdmiller opened this issue Sep 26, 2016 · 0 comments
Open

migrate element card to handle 3 states #127

joshdmiller opened this issue Sep 26, 2016 · 0 comments

Comments

@joshdmiller
Copy link

joshdmiller commented Sep 26, 2016

Overview

Modify the current Element Card to allow for three states: empty, read-only, and editing.

Depends on #135.

UI Concept

Empty State

The checkbox icon is not applicable.

screen shot 2016-09-22 at 4 43 23 pm

Editing State

The existing component's styles for non-read-only instances should be preserved.

screen shot 2016-09-22 at 4 44 36 pm

Read Only

The existing component's styles for read-only instances should be preserved.

The read only state looks like the editing state, but has no footer and no means to interact with it. Reacts to an onclick handler.

Spec

Signature

type ElementCard = {
  _id: string,
  title: ?string,
  content: ?RawDraftContent,
  cover: ?string,
  world_id: ?string,
  files: ?array,
};

type Props = {
  element: ?ElementCard,
  readonly: ?bool = true,
  style: ?Object,

  create: ?func,
  setTitle: ?func,
  setContent: ?func,
  deleteElement: ?func,
  addAttachment: ?func,
  deleteAttachment: ?func,
  setCover: ?func,
};

type RenderedComponent = 'div' | Card;

All props not intended for this component are passed unaltered to the RenderedComponent.

Lifecycle

The component has three states: empty, read-only, and editing.

Empty State

If no element prop is provided, the component is in the empty state. The readonly prop prevents edit/save actions and conversions to other states.

The empty state is intended to indicate that adding a new element is easy. It will eventually be used as the placeholder atop the element list to add a new element (instead of the FAB).

On focus within the placeholder inline edit or on successful upload of an image, the state is transformed into the "Editing State", where adding information to the note is possible.

RenderedComponent = Card;

Editing State

When an element prop is provided and readonly is not truthy, the component is in editing mode.

When in editing mode, the footer is visible, and the title/body are editable. This is equivalent to the current element card when not in read-only.

When in this mode and there is no _id prop and is not awaiting one from a save action (i.e. the element has yet to be created), the save actions (attachments, covers, titles, content changes, etc) must call the create callback, passing in an ElementCard object.

RenderedComponent = 'div';

Read Only

When an element prop is provided and readonly is truthy, the component is in read-only mode.

When in read-only mode, the editor has no footer and all content is displayed read-only. Content within the body is also capped at a specific height and its contents "ghosted" to indicate more content is available. This is equivalent to the current element card when in read-only.

RenderedComponent = Card;
@joshdmiller joshdmiller changed the title [wip] add new element placeholder component migrate element card to handle 3 states Oct 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant