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

element resizing is not working? #22

Closed
kjirou opened this issue Sep 20, 2015 · 2 comments
Closed

element resizing is not working? #22

kjirou opened this issue Sep 20, 2015 · 2 comments

Comments

@kjirou
Copy link
Contributor

kjirou commented Sep 20, 2015

Hello.

I tried to resize a box by like the following code, but it was not working.

import blessed from 'blessed';
import React, { Component } from 'react';
import { render } from 'react-blessed';

const screen = blessed.screen({
  debug: true,
  smartCSR: true,
});

screen.key(['escape', 'C-c'], function(ch, key) {
  return process.exit(0);
});

class Root extends Component {

  constructor() {
    super();

    this.state = {
      top: 0,
      left: 0,
      width: 2,
      height: 1,
    };
  }

  componentDidMount() {
    setInterval(() => {
      this.setState({
        // top and left are applied ..
        top: this.state.top + 1,
        left: this.state.left + 1,
        // .. but width and height are not applied
        width: this.state.width + 1,
        height: this.state.height + 1,
      });
    }, 1000);
  }

  render() {

    let boxProps = Object.assign({
      style: {
        fg: 'white',
        bg: 'magenta',
      },
    }, this.state);

    return (
      <box {...{
        top: 0,
        left: 0,
        width: 40,
        height: 20,
        style: {
          fg: 'white',
          bg: 'blue',
        },
      }}>
        <box {...boxProps}/>
      </box>
    );
  }
}

render(<Root />, screen);

So I added width and height to RAW_ATTRIBUTES (https://github.com/Yomguithereal/react-blessed/blob/master/src/update.js#L9), then it seemed to have moved.

Is this change wrong?


Environments:

  • blessed@0.1.81
  • react@0.14.0-beta3
  • react-blessed@0.1.3
@Yomguithereal
Copy link
Owner

Hello @kjirou. You are right indeed, I forgot bot width and height in RAW_ATTRIBUTES. Do you want to make a pull request with the needed changes, or should I add them?

@kjirou
Copy link
Contributor Author

kjirou commented Sep 21, 2015

@Yomguithereal Thanks for your concern! I did it.

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

2 participants