@namespace Lumeo.Docs.Shared.Patterns
@using Lumeo.Services
@using Lumeo.Docs.Services
@inject ToastService Toast

<Stack Gap="3">
<PatternCard Label="Default Toast" Code="@_codeToastDefault">
    <Button Variant="Button.ButtonVariant.Outline"
            OnClick='() => Toast.Show("Event has been created", "Monday, January 3 at 6:00pm")'>
        Show Toast
    </Button>
</PatternCard>

<PatternCard Label="Destructive Toast" Code="@_codeToastDestructive">
    <Button Variant="Button.ButtonVariant.Destructive"
            OnClick='() => Toast.Error("Something went wrong", "Your request could not be completed.")'>
        Show Error Toast
    </Button>
</PatternCard>

<PatternCard Label="Success Toast" Code="@_codeToastSuccess">
    <Button Variant="Button.ButtonVariant.Outline"
            OnClick='() => Toast.Success("Profile updated", "Your changes have been saved.")'>
        Show Success Toast
    </Button>
</PatternCard>

<PatternCard Label="Warning Toast" Code="@_codeToastWarning">
    <Button Variant="Button.ButtonVariant.Outline"
            OnClick='() => Toast.Warning("Storage almost full", "You have used 90% of your storage.")'>
        Show Warning Toast
    </Button>
</PatternCard>

<PatternCard Label="Info Toast" Code="@_codeToastInfo">
    <Button Variant="Button.ButtonVariant.Outline"
            OnClick='() => Toast.Info("New update available", "Version 2.0 is ready to install.")'>
        Show Info Toast
    </Button>
</PatternCard>

<PatternCard Label="Positions" Code="@_codeToastPositions">
    <Grid Columns="3" Gap="2" Class="w-full max-w-md">
        <Button Variant="Button.ButtonVariant.Outline" Class="text-xs" OnClick="() => ShowToastAt(ToastViewport.ToastPosition.TopLeft)">Top Left</Button>
        <Button Variant="Button.ButtonVariant.Outline" Class="text-xs" OnClick="() => ShowToastAt(ToastViewport.ToastPosition.TopCenter)">Top Center</Button>
        <Button Variant="Button.ButtonVariant.Outline" Class="text-xs" OnClick="() => ShowToastAt(ToastViewport.ToastPosition.TopRight)">Top Right</Button>
        <Button Variant="Button.ButtonVariant.Outline" Class="text-xs" OnClick="() => ShowToastAt(ToastViewport.ToastPosition.BottomLeft)">Bottom Left</Button>
        <Button Variant="Button.ButtonVariant.Outline" Class="text-xs" OnClick="() => ShowToastAt(ToastViewport.ToastPosition.BottomCenter)">Bottom Center</Button>
        <Button Variant="Button.ButtonVariant.Outline" Class="text-xs" OnClick="() => ShowToastAt(ToastViewport.ToastPosition.BottomRight)">Bottom Right</Button>
    </Grid>
</PatternCard>
</Stack>

@code {
    private ToastViewport.ToastPosition _toastPosition = ToastViewport.ToastPosition.BottomRight;

    private void ShowToastAt(ToastViewport.ToastPosition position)
    {
        _toastPosition = position;
        Toast.Show($"{position}", "Position demo");
    }

        private string _codeToastDefault = @"<Button Variant=""Button.ButtonVariant.Outline""
            OnClick='() => Toast.Show(""Event has been created"", ""Monday, January 3 at 6:00pm"")'>
        Show Toast
    </Button>";

        private string _codeToastDestructive = @"<Button Variant=""Button.ButtonVariant.Destructive""
            OnClick='() => Toast.Error(""Something went wrong"", ""Your request could not be completed."")'>
        Show Error Toast
    </Button>";

        private string _codeToastSuccess = @"<Button Variant=""Button.ButtonVariant.Outline""
            OnClick='() => Toast.Success(""Profile updated"", ""Your changes have been saved."")'>
        Show Success Toast
    </Button>";

        private string _codeToastWarning = @"<Button Variant=""Button.ButtonVariant.Outline""
            OnClick='() => Toast.Warning(""Storage almost full"", ""You have used 90% of your storage."")'>
        Show Warning Toast
    </Button>";

        private string _codeToastInfo = @"<Button Variant=""Button.ButtonVariant.Outline""
            OnClick='() => Toast.Info(""New update available"", ""Version 2.0 is ready to install."")'>
        Show Info Toast
    </Button>";

        private string _codeToastPositions = @"<ToastProvider Position=""ToastViewport.ToastPosition.TopRight"" />
    
    // Available positions:
    // TopLeft, TopCenter, TopRight
    // BottomLeft, BottomCenter, BottomRight";
}
