-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-139 Move speed options renderer into a separate component
- Loading branch information
Showing
8 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ghtControl/screens/SendWizardStepTwo/components/SpeedSelector/SpeedSelector.component.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\FlightControl\Screens\SendWizardStepTwo\Components\SpeedSelector; | ||
|
||
// Arguments | ||
// - $props (Object) | ||
// - speedOptions (object) | ||
// - selectedOption (String) | ||
// | ||
// Returns: Object | ||
// - componentHTML (String) | ||
// | ||
function render ($props) { | ||
$speedOptions = $props['speedOptions']; | ||
$selectedOption = $props['selectedOption']; | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$tplBodyCache = [ | ||
'optionBody' => trim($localTemplateLoader('optionBody')), | ||
'optionsSeparator' => trim($localTemplateLoader('optionsSeparator')), | ||
]; | ||
|
||
$optionsListElements = array_map_withkeys($speedOptions, function ($speedOption) use ($selectedOption, &$tplBodyCache) { | ||
$label = $speedOption * 10; | ||
$isSpeedSelected = ($selectedOption == $speedOption); | ||
|
||
return parsetemplate($tplBodyCache['optionBody'], [ | ||
'isSelectedOptionClasses' => ( | ||
$isSpeedSelected ? | ||
'setSpeed_Selected setSpeed_Current' : | ||
'' | ||
), | ||
'optionValue' => $speedOption, | ||
'optionLabel' => $label, | ||
]); | ||
}); | ||
|
||
$elementsListHTML = implode($tplBodyCache['optionsSeparator'], $optionsListElements); | ||
|
||
return [ | ||
'componentHTML' => $elementsListHTML, | ||
]; | ||
} | ||
|
||
?> |
5 changes: 5 additions & 0 deletions
5
modules/flightControl/screens/SendWizardStepTwo/components/SpeedSelector/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
1 change: 1 addition & 0 deletions
1
modules/flightControl/screens/SendWizardStepTwo/components/SpeedSelector/optionBody.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a href="#" class="setSpeed {isSelectedOptionClasses}" data-speed="{optionValue}">{optionLabel}</a> |
1 change: 1 addition & 0 deletions
1
...les/flightControl/screens/SendWizardStepTwo/components/SpeedSelector/optionsSeparator.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<span class="speedBreak">|</span> |
5 changes: 5 additions & 0 deletions
5
modules/flightControl/screens/SendWizardStepTwo/components/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |