Coder Social home page Coder Social logo

Comments (4)

zhdanov avatar zhdanov commented on June 12, 2024 1

Hey @mikeymike thanks! setPaddingLeftRight() works fine!

from cli-menu.

mikeymike avatar mikeymike commented on June 12, 2024

Hey @zhdanov, thanks for the report.

Could you supply an example that shows how you're using this?

We have some code examples in the src, examples/basic-centered.php is one which alters the width which I've played with to also alter colour etc like above but I couldn't recreate a scenario which didn't alter the width.

Thanks!

from cli-menu.

zhdanov avatar zhdanov commented on June 12, 2024

Hey @mikeymike , sure:

<?php
require __DIR__.'/vendor/autoload.php';

use PhpSchool\CliMenu\Builder\CliMenuBuilder;
use PhpSchool\CliMenu\CliMenu;
use PhpSchool\CliMenu\MenuStyle;

$builder = new CliMenuBuilder;

$itemCallable = function ($menu) {
    $style = (new MenuStyle())->setWidth(200)->setBg('black')->setFg('white');

    $result = $menu->askText($style)
        ->setPromptText('Title')
        ->setPlaceholderText('Placeholder')
        ->ask();
};  

$builder->addSubMenu('Item 1', function (CliMenuBuilder $b) use ($itemCallable) {
    $b->setTitle('Menu > Item 1');
    
    $b->addItem('Sub item', function (CliMenu $menu) use ($itemCallable) {
        $itemCallable($menu);
    }); 
});

$menu = $builder->build();

$menu->open();

from cli-menu.

mikeymike avatar mikeymike commented on June 12, 2024

Hey @zhdanov I've had a quick look over this and you're totally right the dialogues don't currently utilise the width set by the style. Instead, these are calculated dynamically based on the parents width, the dialogues content and the dialogue padding styles.

Using setPaddingLeftRight instead of setWidth may be a suitable solution to your problem. I'm going to keep this issue open though as we may want to use width if it's been specifically set and then fallback to dynamic if it's not set.

Thanks again for the report!

from cli-menu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.