Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

feat(editable-title): make page title editable #553

Merged
merged 20 commits into from
Jun 25, 2018
Merged

Conversation

Palmaswell
Copy link
Member

No description provided.

@tilmx tilmx mentioned this pull request Jun 12, 2018
5 tasks
@tilmx tilmx changed the title feat(page-name): WIP inplementation feat(page-name): WIP implementation Jun 12, 2018
@tilmx tilmx changed the title feat(page-name): WIP implementation WIP feat: make page title editable Jun 12, 2018
@Palmaswell Palmaswell changed the title WIP feat: make page title editable feat(editable-title): make page title editable Jun 12, 2018
@Palmaswell Palmaswell requested a review from lkuechler June 12, 2018 15:28
@marionebl
Copy link
Contributor

Looks good, just found an older bug that might be more obvious now.

  1. Edit the name of a page
  2. Make it longer than e.g.: 15xa
  3. text-overflow: ellipsis strikes back

screen shot 2018-06-12 at 23 40 26

Copy link
Contributor

@marionebl marionebl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work, just some comments

import { CopySize } from '../copy';
import { getSpace, SpaceSize } from '../space';

export enum EditState {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be EditableTitleState

Copy link
Member Author

@Palmaswell Palmaswell Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please be aware that the store implementation was not changed in this feature branch.
I did the correction across the model types and the components.

}

const StyledTitle = (props: StyledEditableTitleProps): JSX.Element => {
const Strong = styled.strong`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove StyledTitle and use Strong => StyledStrong directly.

You can add data-title via

const StyledStrong = styled.strong.attrs({ "data-title": true })``

Copy link
Member Author

@Palmaswell Palmaswell Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component was inherited from the master branch and not changed during development.

I made the requested change, but not as proposed. Instead, I am setting the data-attr directly in the consumed Styled component.

<StyledTitle
  data-title={true}
  editable={props.focused}
  fontSize={props.fontSize}
  secondary={props.secondary}
>
  {props.name}
</StyledTitle>

Please note that I did try to use the attr constructor from Styled Components, nevertheless I was encountering problems with Typescript. Below you can see the error message.

Object literal may only specify known properties, and ''data-title'' does not exist in type 'Attrs<DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>,

I would say in this case that the request was fulfilled and the change should be accepted. Thanks!

}

export interface EditableTitleProps {
fontSize?: CopySize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could fontSize be bound to secondary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That totally makes sense. Removed the fontSize prop

focused: boolean;
name: string;
nameState: EditState;
secondary?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this an enum, make it required

export EditableTitleOrder {
   Primary,
   Secondary
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included the new enumerable to categorized the different EditableTitle component. Which I agree to be a good idea to give a much clearer idea of the component props intent :)

Copy link
Member Author

@Palmaswell Palmaswell Jun 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take care now of abstracting the EditableTitleState.Editing and EditableTitleState.Editable store and include it to the container's component own state. I think this is the logical way to proceed in order to solve the problem mentioned below by @tilmx.

# Conflicts:
#	src/components/index.ts
#	src/components/page-tile/demo.tsx
#	src/components/page-tile/index.tsx
#	src/components/view-switch/index.tsx
#	src/container/chrome/chrome-container.tsx
#	src/container/page-list/page-tile-container.tsx
@tilmx
Copy link
Member

tilmx commented Jun 16, 2018

Heyhey! I just merged the current master into this branch. Now, as the title can be edited on the same view both in the chrome and the page pane, it doesn’t work that well any more. When I double-click the chrome page title, it automatically jumps into the page tile editing mode (and not into the "chrome editing mode").

I guess, we have to fix that as well...

@tilmx
Copy link
Member

tilmx commented Jun 19, 2018

Looks fine to me! Just to things:

  • The Page Tiles should have 12px font-size, not 15px (the chrome bar should stay at 15px as it is now)
  • Blurring the title input should save the edited title, not abort it

@Palmaswell Palmaswell merged commit 6834f09 into master Jun 25, 2018
@Palmaswell Palmaswell deleted the feat/page-name branch June 25, 2018 08:53
ashokaditya added a commit to struktr-dk/alva that referenced this pull request Jun 26, 2018
feat(editable-title): make page title editable (meetalva#553)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants