-
Notifications
You must be signed in to change notification settings - Fork 483
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
Some refactoring ahead of implementing the new designs. #3455
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
module Contract.View | ||
( contractDetailsCard | ||
( contractInnerBox | ||
, contractDetailsCard | ||
, actionConfirmationCard | ||
) where | ||
|
||
import Prelude hiding (div) | ||
import Contract.Lenses (_executionState, _metadata, _namedActions, _nickname, _participants, _pendingTransaction, _previousSteps, _selectedStep, _tab, _userParties) | ||
import Contract.Lenses (_executionState, _mMarloweParams, _metadata, _namedActions, _nickname, _participants, _pendingTransaction, _previousSteps, _selectedStep, _tab, _userParties) | ||
import Contract.State (currentStep, isContractClosed) | ||
import Contract.Types (Action(..), PreviousStep, PreviousStepState(..), State, Tab(..), scrollContainerRef) | ||
import Css (applyWhen, classNames, toggleWhen) | ||
|
@@ -21,7 +22,7 @@ import Data.Map (keys, lookup, toUnfoldable) as Map | |
import Data.Maybe (Maybe(..), isJust, maybe, maybe') | ||
import Data.Set (Set) | ||
import Data.Set as Set | ||
import Data.String (take, trim) | ||
import Data.String (null, take, trim) | ||
import Data.String.Extra (capitalize) | ||
import Data.Tuple (Tuple(..), fst, uncurry) | ||
import Data.Tuple.Nested ((/\)) | ||
|
@@ -40,6 +41,39 @@ import Marlowe.Slot (secondsDiff, slotToDateTime) | |
import Material.Icons (Icon(..), icon) | ||
import WalletData.State (adaToken, getAda) | ||
|
||
-- I'm moving this view here so that we can easily call Contract.Actions from inside it. I'm not | ||
-- actually calling any Contract.Actions from here yet, but that's a TODO for the next PR... | ||
contractInnerBox :: forall p. Slot -> State -> HTML p Action | ||
contractInnerBox currentSlot state = | ||
Comment on lines
+44
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same that previous If so, it looks a lot smaller, it's missing the contractType, Acronym and contractInstanceId 🤔 . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't the whole box (hence "inner"). I left the parent div and the header in the dashboard view, because that needs to have a clickable element that opens the screen for that contract - which is a dashboard action. But then the rest goes here in the contract view, because it will have contract actions. |
||
let | ||
nickname = state ^. _nickname | ||
|
||
mMarloweParams = state ^. _mMarloweParams | ||
|
||
stepNumber = currentStep state + 1 | ||
|
||
mNextTimeout = state ^. (_executionState <<< _mNextTimeout) | ||
|
||
timeoutStr = | ||
maybe' | ||
(\_ -> if isContractClosed state then "Contract closed" else "Timed out") | ||
(\nextTimeout -> humanizeDuration $ secondsDiff nextTimeout currentSlot) | ||
mNextTimeout | ||
in | ||
div_ | ||
[ div | ||
[ classNames [ "flex-1", "px-4", "py-2", "text-lg" ] ] | ||
-- TODO: make (new) nicknames editable directly from here | ||
[ text if null nickname then "My new contract" else nickname ] | ||
, div | ||
[ classNames [ "bg-lightgray", "flex", "flex-col", "px-4", "py-2" ] ] case mMarloweParams of | ||
Nothing -> [ text "pending confirmation" ] | ||
_ -> | ||
[ span [ classNames [ "text-xs", "font-semibold" ] ] [ text $ "Step " <> show stepNumber <> ":" ] | ||
, span [ classNames [ "text-xl" ] ] [ text timeoutStr ] | ||
] | ||
] | ||
|
||
-- NOTE: Currently, the horizontal scrolling for this element does not match the exact desing. In the designs, the active card is always centered and you | ||
-- can change which card is active via scrolling or the navigation buttons. To implement this we would probably need to add snap scrolling to the center of the | ||
-- big container and create a smaller absolute positioned element of the size of a card (positioned in the middle), and with JS check that if a card enters | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more keen into renaming the current cards into
modal
ordialog
and keepingcard
for this widget. Or even keeping justcard
for modals and this being acontractCard
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InnerBox is particulary noisy, as a Box is a 3d element, and an inner box I'm thinking about a box inside a box.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. I'll leave it for now and rename things in the next PR - when I expect these things will become clearer. I'm not opposed to either of your suggestions.